eolymp
bolt
Try our new interface for solving problems
Problems

Competition

Competition

k competitors are taking part in a competition. Each of them must finish n full laps of a round circuit. All the competitors start together from the starting line. At the start of the event every runner is in his 'normal' form. While making his laps he is losing his stamina and he is running with lower and lower tempo. That lower tempo means that every lap is done 1 millisecond slower than the previous one. When in normal form competitor with number i is doing one lap for msi milliseconds (msi is a positive integer). The rules of the competition allow a positive integer pi (1pin) to be announced for every competitor before the start. On every full pi laps done the runner gets an energy drink (while passing the starting line) which returns him to full strength (after that his stamina is dropping again the same way as before). The drinking takes 0 time. It's obvious that while doing n laps every competitor will cross the starting line n times (we count the crossing after the last lap, but do not count the crossing of the line when they start the run).

Write a program, which determines the maximum number of competitors who will cross the starting line together at any point of the competition (as we are working in milliseconds "together" means after equal amount of milliseconds after the competition's start).

Input

On the first line you must read two positive integers, separated with an interval: k (2k10000) - competitors count and n (1n1000) - laps count.

After that there are k rows (one for each runner). On every row there are two positive integers: msi (1msi106) - milliseconds for competitor i to run one lap in "normal" form and pi (1pin) - lap count on which the runner receives his energy drinks and returns to "normal" form.

Output

Print one single integer - the determined maximum count of competitors who will cross the starting line together at some moment of the competition.

Explanation

The runners will do the following laps:

Runner1 - for 26, 27 and 26 msec.; Runner2 - for 39, 40 and 41 msec.; Runner3 - for 45, 45 and 45 msec.; Runner4 - for 56, 57 and 56 msec. Respectively they will cross the starting line at: Runner1 - after 26, 53, 79 msec.; Runner2 - after 39, 79 and 120 msec; Runner3 - after 45, 90 and 135 msec; Runner4 - after 56, 113 and 169 msec. The only case when more than one runner will cross the starting line is after 79 milliseconds when runner1 and runner2 will be on the line together.

Time limit 2 seconds
Memory limit 128 MiB
Input example #1
4 3
26 2
39 3
45 1
56 2




Output example #1
2
Source 2010 II International autumn tournament in informatics, Shumen, Junior, Problem B