#include using namespace std; typedef long long LL; const int maxn = 200005; struct P { LL x, y; }; P a[maxn]; bool cmp(P p, P q) { if (p.x != q.x) { return p.x < q.x; } return p.y < q.y; } LL LLabs(LL x) { if (x < 0) return -x; else return x; } int main() { freopen("group.in", "r", stdin); freopen("group.out", "w", stdout); LL a1, b1, c1, d1; cin >> a1 >> b1 >> c1 >> d1; int n; cin >> n; LL det = a1 * d1 - b1 * c1; for (int i = 1; i <= n; i++) { LL x, y; cin >> x >> y; if (a1 == 0 && b1 == 0 && c1 == 0 && d1 == 0) { a[i].x = x; a[i].y = y; } else if (det != 0) { LL u = __int128(d1 * x) - __int128(c1 * y); LL v = -__int128(b1 * x) + __int128(a1 * y); LL m = LLabs(det); u %= m; v %= m; if (u < 0) { u += m; } if (v < 0) { v += m; } a[i].x = u; a[i].y = v; } else { LL dx = a1, dy = b1; if (dx == 0 && dy == 0) { dx = c1; dy = d1; } LL k = __int128(dx * y) - __int128(dy * x); a[i].x = k; a[i].y = 0; } } sort(a + 1, a + n + 1, cmp); int ans = 0; for (int i = 1; i <= n; i++) { if (i == 1 || a[i].x != a[i - 1].x || a[i].y != a[i - 1].y) { ans++; } } cout << ans << endl; return 0; }