#include <bits/stdc++.h>
int main() {
  double x1, y1, x2, y2;
  scanf("%lf%lf", &x1, &y1);
  scanf("%lf%lf", &x2, &y2);
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    double a, b, c;
    scanf("%lf%lf%lf", &a, &b, &c);
    if ((a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0) ans++;
  }
  printf("%d\n", ans);
}
