#include <bits/stdc++.h>
using namespace std;
double x1, y, x2, y2;
int judge1(double a, double b, double c) {
  double tmp;
  if (b != 0) {
    tmp = (-c - a * x1) / b;
    if (tmp > y)
      return 1;
    else
      return -1;
  } else {
    if (x1 < (-c / a))
      return 1;
    else
      return -1;
  }
}
int judge2(double a, double b, double c) {
  double tmp;
  if (b != 0) {
    tmp = (-c - a * x2) / b;
    if (tmp > y2)
      return 1;
    else
      return -1;
  } else {
    if (x2 < (-c / a))
      return 1;
    else
      return -1;
  }
}
int main() {
  scanf("%lf %lf", &x1, &y);
  scanf("%lf %lf", &x2, &y2);
  int n, cnt = 0;
  double a, b, c;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf %lf %lf", &a, &b, &c);
    if (judge1(a, b, c) * judge2(a, b, c) < 0) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}
