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