#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
} w[2];
int32_t main() {
  long long ans = 0;
  for (long long i = 0; i < 2; i++) {
    scanf("%lld%lld", &w[i].x, &w[i].y);
  }
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    long long R = a * w[0].x + c;
    R *= -1;
    bool K1 = w[0].y * b < R;
    R = a * w[1].x + c;
    R *= -1;
    bool K2 = w[1].y * b < R;
    if (K1 != K2) ans++;
  }
  printf("%lld\n", ans);
}
