#include <bits/stdc++.h>
using namespace std;
long long int x, y, x2, y2, a, b, c, n, d[307];
string s1[3007], s2[3007], les[3007];
void solve() {
  long long int i, last = 1, l, j, s = 0, q, w, e, r, t, k = 0;
  scanf("%I64d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d%I64d", &a, &b, &c);
    q = a * x;
    w = b * y;
    e = a * x2;
    r = b * y2;
    if ((q + w + c > 0 && e + r + c < 0) || (q + w + c < 0 && e + r + c > 0)) {
      s++;
    }
  }
  printf("%I64d\n", s);
}
int main() {
#pragma comment(linker, "/STACK:67108864")
  while (scanf("%I64d%I64d%I64d%I64d", &x, &y, &x2, &y2) != EOF) {
    solve();
  }
  return 0;
}
