#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first < b.first;
}
long long exp(long long a, long long b) {
  long long ans = 1;
  while (b != 0) {
    if (b % 2) ans = ans * a;
    a = a * a;
    b /= 2;
  }
  return ans;
}
int main() {
  long long a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  long long n;
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)n; i++) {
    long long e, f, g;
    scanf("%lld %lld %lld", &e, &f, &g);
    long long val1 = e * a + f * b + g;
    long long val2 = e * c + f * d + g;
    if (val1 < 0 && val2 > 0 || (val1 > 0 && val2 < 0)) {
      ans++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
