#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int line(long long x, long long y) {
  long long ret = a * 1LL * x + b * 1LL * y + c * 1LL;
  if (ret < 0)
    return -1;
  else
    return 1;
}
int main() {
  int x1, y1, x2, y2;
  scanf("%I64d %I64d", &x1, &y1);
  scanf("%I64d %I64d", &x2, &y2);
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%I64d %I64d %I64d", &a, &b, &c);
    if (line(x1, y1) != line(x2, y2)) ++ans;
  }
  printf("%d", ans);
  return 0;
}
