#include <bits/stdc++.h>
using namespace std;
long long bgm(long long a, long long b, long long m) {
  a %= m;
  long long rem = 1;
  while (b) {
    if (b & 1) rem = (rem * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return rem;
}
long long inv(long long a, long long mod) { return bgm(a, mod - 2, mod); }
long long in() {
  long long a;
  assert(scanf("%lld", &a) != EOF);
  return a;
}
double dl() {
  double a;
  assert(scanf("%lf", &a) != EOF);
  return a;
}
const int MAX = 105;
const int LEN = 13;
const long long MOD = 1000000007;
double ttm;
long long x1, x2, yy1, y2;
int n;
long long a, b, c;
long long xx, yy;
long long ans;
int main() {
  x1 = in(), yy1 = in(), x2 = in(), y2 = in();
  n = in();
  while (n--) {
    a = in(), b = in(), c = in();
    xx = a * x1 + b * yy1 + c;
    yy = a * x2 + b * y2 + c;
    ans += (xx > 0 and yy < 0) or (xx < 0 and yy > 0);
  }
  printf("%lld", (long long)(ans)), puts("");
  return 0;
}
