#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int main() {
  double X1, X2, Y1, Y2;
  scanf("%lf%lf%lf%lf", &X1, &Y1, &X2, &Y2);
  int ans = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; 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) < eps) {
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
