#include <bits/stdc++.h>
const int maxn = 500;
int ax, ay, bx, by;
int n;
int a[maxn], b[maxn], c[maxn];
int side[maxn];
int main() {
  scanf("%d%d", &ax, &ay);
  scanf("%d%d", &bx, &by);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    if (1LL * a[i] * ax + 1LL * b[i] * ay + c[i] > 0)
      side[i] = 1;
    else
      side[i] = -1;
  }
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    int val;
    if (1LL * a[i] * bx + 1LL * b[i] * by + c[i] > 0)
      val = 1;
    else
      val = -1;
    if (val != side[i]) ++tot;
  }
  printf("%d\n", tot);
  return 0;
}
