Under construction

Still being built. Things may change

Teacher Cho Force

Time limit2sMemory limit128 MB

Summary
Given a moving catcher and N moving students, compute the maximum number of students that can simultaneously lie within radius R at any nonnegative time.
Level

Medium7 of 10

Topics
Intervals, Math, Sorting, Geometry
Solved
No attempts yet

Problem

During programming class, the students keep talking. Teacher Cho finally starts running to catch them, and the NN noisy students start running away at the same time.

Initially, Teacher Cho is at (BX,BY)(B_X, B_Y). Since Teacher Cho moves by vector (BVX,BVY)(BV_X, BV_Y) each second, after tt seconds the position is (BX+BVX×t,BY+BVY×t)(B_X + BV_X \times t, B_Y + BV_Y \times t).

Student ii starts at (Xi,Yi)(X_i, Y_i) and moves by vector (VXi,VYi)(VX_i, VY_i) each second. After tt (t≥0t \ge 0) seconds, the student's position is (Xi+VXi×t,Yi+VYi×t)(X_i + VX_i \times t, Y_i + VY_i \times t).

At one chosen moment, Teacher Cho can catch every student inside the circle of radius RR centered at Teacher Cho's current position. Once that chance is used, all uncaught students escape, so Teacher Cho wants to choose a time that maximizes the number of students caught at once.

Given all initial positions and movement vectors, find the maximum number of students Teacher Cho can catch in one attempt. The best time may be non-integer.

Input

The first line contains the number of students NN, the catching radius RR, Teacher Cho's initial position BXB_X, BYB_Y, and Teacher Cho's movement vector BVXBV_X, BVYBV_Y, separated by spaces.

Each of the next NN lines describes one student. A line contains the student's initial position XiX_i, YiY_i and movement vector VXiVX_i, VYiVY_i, separated by spaces.

Output

Print the maximum number of students Teacher Cho can catch in one attempt.

For floating-point tolerance, a student is considered catchable even when the distance between the student and Teacher Cho is within R±0.0001R \pm 0.0001.

Constraints

  • 1≤N≤50,0001 \le N \le 50,000
  • 1≤R≤2,5001 \le R \le 2,500
  • −1,000≤BX,BY≤1,000-1,000 \le B_X, B_Y \le 1,000
  • −100≤BVX,BVY≤100-100 \le BV_X, BV_Y \le 100
  • −1,000≤Xi,Yi,VXi,VYi≤1,000-1,000 \le X_i, Y_i, VX_i, VY_i \le 1,000
  • Every input value is an integer.

Hint

In the first sample, after 1.51.5 seconds Teacher Cho is at (0,3)(0, 3). The students are at (0,3)(0, 3), (−0.5,3.5)(-0.5, 3.5), and (4,−3.5)(4, -3.5), so students 1 and 2 are within radius 11. No time catches more students.

Examples1

  1. Example 1

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