#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  point(){};
  point(double _x, double _y) { x = _x, y = _y; }
};
point s, e;
double det(double a, double b, double c, double d) { return (a * d - b * c); }
point perpotongan(point p1, point p2, point p3, point p4) {
  point has;
  has.x = -137;
  has.y = -1134;
  double d1 = det(p1.x, p1.y, p2.x, p2.y);
  double d2 = det(p1.x, 1, p2.x, 1);
  double d3 = det(p3.x, p3.y, p4.x, p4.y);
  double d4 = det(p3.x, 1, p4.x, 1);
  double d5 = det(p1.x, 1, p2.x, 1);
  double d6 = det(p1.y, 1, p2.y, 1);
  double d7 = det(p3.x, 1, p4.x, 1);
  double d8 = det(p3.y, 1, p4.y, 1);
  double top = det(d1, d2, d3, d4);
  double bot = det(d5, d6, d7, d8);
  if (bot == 0) return (has);
  has.x = top / bot;
  d2 = det(p1.y, 1, p2.y, 1);
  d4 = det(p3.y, 1, p4.y, 1);
  top = det(d1, d2, d3, d4);
  has.y = top / bot;
  return (has);
}
double dist(point p1, point p2) { return hypot(p1.x - p2.x, p1.y - p2.y); }
int main() {
  scanf("%lf %lf", &s.x, &s.y);
  scanf("%lf %lf", &e.x, &e.y);
  int n;
  scanf("%d", &n);
  double a, b, c;
  point p, q;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lf %lf %lf", &a, &b, &c);
    double kiri = a * s.x + b * s.y + c;
    double kanan = a * e.x + b * e.y + c;
    if (((kiri > 0) && (kanan < 0)) || ((kiri < 0) && (kanan > 0))) ++ans;
  }
  printf("%d\n", ans);
}
