#include <bits/stdc++.h>
using namespace std;
const int N = 305;
long long x1, my_y1;
long long x2, y2;
int n;
long long a[N], b[N], c[N];
int sgn(long long x) {
  if (x < 0) return -1;
  if (x == 0) return 0;
  return 1;
}
int get_side(int i, long long x, long long y) {
  return sgn(a[i] * x + b[i] * y + c[i]);
}
void solve() {
  scanf("%lld%lld", &x1, &my_y1);
  scanf("%lld%lld", &x2, &y2);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (get_side(i, x1, my_y1) != get_side(i, x2, y2)) cnt++;
  printf("%d\n", cnt);
}
int main() {
  solve();
  0;
  return 0;
}
