#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; typedef pair PP; const int mod = 1000000007; const int INF = 1e18; int gcd(int a, int b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a % b); } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int a, b, c, d; cin >> a >> b >> c >> d; int n; cin >> n; if(a * d - b * c == 0){ set

st; rep(i, 0, n){ int x, y; cin >> x >> y; P v; v.first = a * y - b * x; v.second = a; int G = gcd(abs(v.first), abs(v.second)); v.first /= G; v.second /= G; st.insert(v); } cout << st.size() << endl; return 0; } set st; rep(i, 0, n){ int x, y; cin >> x >> y; P u, v; u.second = v.second = a * d - b * c; u.first = d * x - c * y; v.first = a * y - b * x; if(u.second < 0){ u.first *= -1; u.second *= -1; v.first *= -1; v.second *= -1; } int G = gcd(abs(u.first), abs(u.second)); u.first /= G; u.second /= G; u.first = (u.first % u.second + u.second) % u.second; G = gcd(abs(v.first), abs(v.second)); v.first /= G; v.second /= G; v.first = (v.first % v.second + v.second) % v.second; st.insert({u, v}); } cout << st.size() << endl; }