#include #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define VAR(type, a) type a;std::cin>>a; // VAR(int, x); #define OUT(d) std::cout<<(d); #define SP std::cout<<" "; #define TAB std::cout<<"\t"; #define BR std::cout<<"\n"; #define ENDL std::cout< c(n);for(auto& i:c)std::cin>>i; #define MAT(type, c, m, n) std::vector> c(m, std::vector(n));for(auto& r:c)for(auto& i:r)std::cin>>i; #define ALL(a) (a).begin(),(a).end() #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define POS std::pair #define IN(a0, y, a1, b0, x, b1) (a0<=y && y x(n), y(n); REP(i, n){ std::cin >> x[i] >> y[i]; x[i] = std::fabs(x[i]); y[i] = std::fabs(y[i]); } int cnt = 0; if(p==0 && q==0){ REP(i, n)if(x[i]==0 && y[i]==0) ++cnt; } else if(p==0 || q==0){ int t = std::max(p, q); REP(i, n)if(x[i]%t==0 && y[i]%t==0) ++cnt; } else{ ll t = GCD(p, q); if(p%2==q%2){ REP(i, n)if(x[i]%t==0 && y[i]%t==0 /*&& (x[i]+y[i])%(t*2)==0*/) ++cnt; } else{ REP(i, n)if(x[i]%t==0 && y[i]%t==0) ++cnt; } } OUT(cnt)BR; return 0; }