#include <bits/stdc++.h>
struct point {
  long double x, y;
  point() {}
  point(long double _x, long double _y) : x(_x), y(_y) {}
};
point p1, p2, p3, p4;
int a, b, c;
int n, ans;
long double cross(point a, point b) { return a.x * b.y - a.y * b.x; }
point tovec(point a, point b) { return point(b.x - a.x, b.y - a.y); }
bool ccw(point p1, point p2, point p3) {
  return cross(tovec(p1, p2), tovec(p2, p3)) > 0;
}
int main() {
  scanf("%Lf%Lf%Lf%Lf%d", &p1.x, &p1.y, &p2.x, &p2.y, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (a) {
      p3.y = 1e6 + 1;
      p3.x = (long double)(-c - (b * p3.y)) / (long double)a;
      p4.y = -1e6 - 1;
      p4.x = (long double)(-c - (b * p4.y)) / (long double)a;
    } else {
      p3.x = 1e6 + 1;
      p3.y = (long double)(-c - (a * p3.x)) / (long double)b;
      p4.x = -1e6 - 1;
      p4.y = (long double)(-c - (a * p4.x)) / (long double)b;
    }
    if (ccw(p1, p2, p3) != ccw(p1, p2, p4) &&
        ccw(p3, p4, p1) != ccw(p3, p4, p2)) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
