Walking

Interview

Time limit1sMemory limit128 MB

Summary
Walkers start at distinct times with fixed speeds, and a later starter who arrives earlier befriends the other; find the largest group where every pair meets.
Level

Medium4 of 10

Topics
Dynamic programming, Sorting
Solved
No attempts yet

Problem

Consider a road of length ℓ\ell. There are nn persons. The iith person, for i=1,…,ni = 1, \ldots, n, starts walking from the beginning of the road at time tit_i and moves at a constant speed viv_i until arrival at the end of the road. No two persons start walking at the same time, and no two persons arrive at the same time.

If the iith and the jjth person meet each other on the road, they become friends. Written as a formula, for two persons ii and jj with ti<tjt_i < t_j, they become friends if and only if ℓ/vi+ti>ℓ/vj+tj\ell / v_i + t_i > \ell / v_j + t_j.

Find the size of the largest set of persons who are all friends of each other.

Input

Your program must read from the standard input. The input consists of n+1n + 1 lines. The first line contains two integers ℓ\ell and nn separated by a single space, where 100≤ℓ≤10000100 \le \ell \le 10000 and 1≤n≤5001 \le n \le 500. Of the next nn lines, line i+1i + 1 contains two integers tit_i and viv_i separated by a single space, where 0≤ti≤10000 \le t_i \le 1000 and 1≤vi≤1001 \le v_i \le 100.

Output

Your program must write one integer to the standard output. That integer is the size of the largest set of persons who are all friends of each other.

Examples2

  1. Example 1

    Input
    1000 4
    1 3
    2 1
    0 2
    3 4
    
    Expected output
    3
    
  2. Example 2

    Input
    1000 4
    0 1
    2 1
    1 1
    3 1
    
    Expected output
    1