#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair P; ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b); } int main() { ll p, q; cin>>p>>q; ll d=gcd(p, q); int n; cin>>n; int ct=0; for(int i=0; i>x>>y; if(p==0 && q==0){ if(x==0 && y==0) ct++; }else{ if(x%d==0 && y%d==0){ if((p/d+q/d)%2!=0) ct++; else if((x/d+y/d)%2==0) ct++; } } } cout<