Competition#8583

Competition

2 seconds
128 megabytes
Medium

competitors are taking part in a competition. Each of them must finish 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 millisecond slower than the previous one. When in normal form competitor with number is doing one lap for ms_i milliseconds (ms_i is a positive integer). The rules of the competition allow a positive integer p_i (1 \le p_i \le n) to be announced for every competitor before the start. On every full p_i 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 time. It's obvious that while doing laps every competitor will cross the starting line 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

The first line contains two positive integers, separated by a space: (2 \le k \le 10000) - competitors count and (1 \le n \le 1000) - laps count.

After that there are rows (one for each runner). On every row there are two positive integers: ms_i (1 \le ms_i \le 10^6) - milliseconds for competitor to run one lap in "normal" form and p_i (1 \le p_i \le n) - 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.

Examples

Example 1

Loading
Loading

Note

The runners will do the following laps:

Runner1 - for , and msec.; Runner2 - for , and msec.; Runner3 - for , and msec.;Runner4 - for , and msec. Respectively they will cross the starting line at: Runner1 - after , , msec.; Runner2 - after , and msec; Runner3 - after , and msec; Runner4 - after , and msec. The only case when more than one runner will cross the starting line is after milliseconds whenrunner1 and runner2 will be on the line together.