#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  point() { x = y = 0.0; }
  point(double _x, double _y) : x(_x), y(_y) {}
};
struct vec {
  double x, y;
  vec(double _x, double _y) : x(_x), y(_y) {}
};
vec toVector(point a, point b) { return vec(b.x - a.x, b.y - a.y); }
double crossProd(vec a, vec b) { return a.x * b.y - a.y * b.x; }
bool CCW(point p, point q, point r) {
  return crossProd(toVector(p, q), toVector(p, r)) > 0;
}
int main() {
  int x, y, n, res = 0;
  double a, b, c;
  point strt, fnsh;
  scanf("%d %d", &x, &y);
  strt = point(x, y);
  scanf("%d %d", &x, &y);
  fnsh = point(x, y);
  scanf("%d", &n);
  while (n--) {
    scanf("%lf %lf %lf", &a, &b, &c);
    point p, q;
    if (!a) {
      p = point(0, -c / b);
      q = point(1, -c / b);
    } else if (!b) {
      p = point(-c / a, 0);
      q = point(-c / a, 1);
    } else if (!c) {
      p = point(0, 0);
      q = point(1, -a / b);
    } else {
      p = point(0, -c / b);
      q = point(-c / a, 0);
    }
    res += (CCW(p, q, strt) ^ CCW(p, q, fnsh));
  }
  printf("%d", res);
}
