#include <bits/stdc++.h>
using namespace std;
const int N = 310;
long long xh, yh, xu, yu;
int n;
long long a[N], b[N], c[N];
int main() {
  scanf("%I64d%I64d", &xh, &yh);
  scanf("%I64d%I64d", &xu, &yu);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%I64d%I64d%I64d", a + i, b + i, c + i);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] * xu + b[i] * yu + c[i] < 0 && a[i] * xh + b[i] * yh + c[i] > 0) {
      ++cnt;
    } else if (a[i] * xu + b[i] * yu + c[i] > 0 &&
               a[i] * xh + b[i] * yh + c[i] < 0) {
      ++cnt;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
