World Cup Draws

Given each team's total points and the number of games played, work out how many of those games ended in a draw.

Easy3MathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

A button football World Cup is being played with teams from all over the world. Teams are ranked by the points they have earned, and points are awarded the usual way. A team that wins a game gets 3 points, a game that ends in a draw gives 1 point to each of the two teams, and the losing team gets nothing.

You are given the current standings and the number of participating teams. Determine how many games have ended in a draw so far.

Input

The input contains several test cases. The first line of a test case has two integers TT and NN, the number of participating teams (2T2002 \le T \le 200) and the number of games played so far (0N100000 \le N \le 10000). Each of the next TT lines has the name of a team (a string of at most 10 letters and digits), one space, and the number of points that team has earned so far. The point total is always a value that the NN games could actually have produced.

The last line of the input starts with T=0T = 0 and is not a test case.

Output

For each test case, print one line with a single integer, the number of games that have ended in a draw so far.