This page is still under construction.

Parts of this page are still being built. What you see may change.

Captain Latvia

Time limit1sMemory limit1024 MB

Summary
Choose left and right wall points so the triangle through (X,0) covers as many given enemy points as possible; output the maximum count.
Level

Medium7 of 10

Topics
Geometry, Greedy, Sorting, Brute force
Solved
No attempts yet

Statement

Consider an infinitely long corridor drawn in the plane. Its floor (the bottom wall) is the segment from (0,0)(0, 0) to (L,0)(L, 0). Its two side walls are the rays that start at (0,0)(0, 0) and (L,0)(L, 0) and extend upward (in the direction of increasing yy). Thus the corridor is the set of all points with 0≤x≤L0 \le x \le L and y≥0y \ge 0.

There are NN enemies in the corridor. The ii-th enemy stands at the point (xi,yi)(x_i, y_i), where 0<xi<L0 < x_i < L and yi>0y_i > 0.

The hero stands at the point (X,0)(X, 0) on the floor, where 0<X<L0 < X < L, and throws a shield without moving. The shield flies in a straight line to a point on one side wall, bounces to a point on the other side wall, and then flies straight back to the hero. Its trajectory is therefore a triangle whose three vertices are the hero's position (X,0)(X, 0), a point on the left wall, and a point on the right wall. Every enemy that lies on the boundary of this triangle (on any of its three edges) is knocked out.

The hero may aim freely: the two wall vertices may be placed anywhere on the walls, at any height ≥0\ge 0. Find the maximum number of enemies that can be knocked out with a single throw.

Input

The first line contains two integers LL and NN — the length of the floor and the number of enemies. The second line contains one integer XX — the hero's xx-coordinate. Each of the next NN lines contains two space-separated integers xix_i and yiy_i — the coordinates of the ii-th enemy.

Output

Print one integer — the maximum number of enemies that can be knocked out with a single throw.

Constraints

  • 1≤N≤1051 \le N \le 10^5
  • 2≤L≤1052 \le L \le 10^5
  • 0<X<L0 < X < L
  • 0<xi<L0 < x_i < L
  • 0<yi≤1050 < y_i \le 10^5
  • All coordinates are integers.

Examples3

  1. Example 1

    Input
    5 5
    2
    1 1
    1 4
    4 2
    3 3
    2 6
    
    Expected output
    3
    
  2. Example 2

    Input
    10 1
    5
    5 7
    
    Expected output
    1
    
  3. Example 3

    Input
    10 2
    5
    2 3
    8 3
    
    Expected output
    2