#include <bits/stdc++.h>
using namespace std;
long long n;
pair<long long, long long> a, b;
pair<pair<long long, long long>, long long> ar[10100];
long long A[10100], B[10100], ans;
int main() {
  scanf("%I64d%I64d", &a.first, &a.second);
  scanf("%I64d%I64d", &b.first, &b.second);
  scanf("%I64d", &n);
  for (long long i = 0; i < n; i++)
    scanf("%I64d%I64d%I64d", &ar[i].first.first, &ar[i].first.second,
          &ar[i].second);
  memset(A, 0, sizeof(A));
  memset(B, 0, sizeof(B));
  ans = 0;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    long long aa, bb, cc;
    aa = ar[i].first.first;
    bb = ar[i].first.second;
    cc = ar[i].second;
    x = a.first;
    y = a.second;
    A[i] = (aa * x + bb * y + cc > 0);
    x = b.first;
    y = b.second;
    B[i] = (aa * x + bb * y + cc > 0);
    if (A[i] != B[i]) ans++;
  }
  printf("%I64d\n", ans);
  return 0;
}
