#include using namespace std; #define FOR(a, b, c) for(int a = (b); a < (c); a++) using ll = long long; #define LL long long using LD = long double; using PLD = pair; using PLL = pair; const int N = 3e5 + 7; const LD eps = 1e-6; template T dotProduct(pair a, pair b) { return a.first * b.first + a.second * b.second; } template T crossProduct(pair a, pair b) { return a.first * b.second - a.second * b.first; } template T lengthPow(pair a) { return dotProduct(a,a); } template LD length(pair a) { return sqrtl(lengthPow(a)); } pair pos[N]; LD pointLineDistance(PLD p , PLD a, PLD dir) { PLD newVec = {p.first - a.first, p.second - a.second}; return abs(crossProduct(newVec, dir) / length(dir)); } pair circleLineIntersection (PLL o, LL r, PLL a, PLL dir) { PLL vec = {a.first - o.first, a.second - o.second}; if(pointLineDistance(o, a, dir) > r) return {false, PLD{0,0}}; LD x = vec.first; LD y = vec.second; LD D = dir.first; LD K = dir.second; LD root = r*r*K*K - x*x*K*K + 2 * D * x * y * K + D*D*r*r - D*D*y*y; root = sqrtl(root); LD t1 = (-D * x - y * K + root) / (D * D + K * K); LD t2 = (-D * x - y * K - root) / (D * D + K * K); if(t1 > t2) swap(t1,t2); return {true,{t1,t2}}; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; LL r; pair s, e; cin >> n >> r >> e.first >> e.second; s = {0,0}; LD length = lengthPow(e); LD bestX ; LD bestY ; if(e != PLL{0,0}) { vector > przedzialy; FOR(i,0,n) { LL x, y; cin >> x >> y; pos[i] = {x,y}; auto res = circleLineIntersection({x,y}, r, s, e); if(res.first) { auto fir = res.second.first; auto sec = res.second.second; przedzialy.push_back({fir, 0}); przedzialy.push_back({sec, 1}); } } sort(przedzialy.begin(), przedzialy.end()); int ile = 0; LD best = -1e6; LL bestIle = 0; for(auto u : przedzialy) { if(u.second == 0) { ++ile; if(ile > bestIle) { bestIle = ile; best = u.first + eps; } } else --ile; } bestX = e.first * best; bestY = e.second * best; } else { bestX = 0; bestY = 0; } int res = 0; for(int i = 0; i < n; ++i) { PLD dir = {pos[i].first - bestX, pos[i].second - bestY}; if(lengthPow(dir) <= r * r + eps) ++res; } cout << res << '\n'; }