#include <bits/stdc++.h>
using namespace std;
double ax, ay, bx, by;
bool check(double x, double y) {
  int ok = 0;
  if (x <= max(ax, bx) && x >= min(ax, bx)) ok++;
  if (y <= max(ay, by) && y >= min(ay, by)) ok++;
  return ok == 2 ? true : false;
}
double a, b, c, p, q;
void cal(double &cx, double &cy) {
  if (fabs(b) < 1e-8) {
    cx = -c / a;
    cy = p * cx + q;
  } else {
    cx = (-c - b * q) / (b * p + a);
    cy = p * cx + q;
  }
}
int main() {
  int n, x, y, xx, yy;
  scanf("%d%d%d%d", &x, &y, &xx, &yy);
  ax = (double)x, ay = (double)y;
  bx = (double)xx, by = (double)yy;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%lf %lf %lf", &a, &b, &c);
    if (x == xx) {
      if (fabs(b) < 1e-8) continue;
      bool ok = check(ax, (-c - a * ax) / b);
      if (ok) ans++;
    } else {
      p = (by - ay) / (bx - ax);
      q = (ay * bx - by * ax) / (bx - ax);
      double cx, cy;
      if (fabs(-a / b - p) < 1e-8) continue;
      cal(cx, cy);
      bool ok = check(cx, cy);
      if (ok) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
