#include <bits/stdc++.h>
int main() {
  long long x1, y1, x2, y2;
  long long n, a, b, c, i;
  long long tmp1, tmp2;
  int res = 0;
  scanf("%I64d %I64d", &x1, &y1);
  scanf("%I64d %I64d", &x2, &y2);
  scanf("%I64d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%I64d %I64d %I64d", &a, &b, &c);
    tmp1 = a * x1 + b * y1 + c;
    tmp2 = a * x2 + b * y2 + c;
    if ((tmp1 > 0 && tmp2 < 0) || (tmp1 < 0 && tmp2 > 0)) ++res;
  }
  printf("%d\n", res);
  return 0;
}
