#include <bits/stdc++.h>
using namespace std;
const double eps(1e-9);
inline int sgn(double x) {
  if (x < -eps) return -1;
  if (x > eps) return 1;
  return 0;
}
struct Point {
  double x, y;
  Point(void) {}
  Point(const double _x, const double _y) : x(_x), y(_y) {}
};
inline bool operator==(const Point &a, const Point &b) {
  return !(sgn(a.x - b.x) || sgn(a.y - b.y));
}
inline bool operator!=(const Point &a, const Point &b) {
  return sgn(a.x - b.x) || sgn(a.y - b.y);
}
inline Point operator+(const Point &a, const Point &b) {
  return Point(a.x + b.x, a.y + b.y);
}
inline Point operator-(const Point &a, const Point &b) {
  return Point(a.x - b.x, a.y - b.y);
}
inline Point operator*(const Point &a, double b) {
  return Point(a.x * b, a.y * b);
}
inline Point operator*(double b, const Point &a) {
  return Point(a.x * b, a.y * b);
}
inline Point operator/(const Point &a, double b) {
  return Point(a.x / b, a.y / b);
}
inline double sqr(const Point &x) { return x.x * x.x + x.y * x.y; }
inline double abs(const Point &x) { return sqrt(sqr(x)); }
inline double dist(const Point &a, const Point &b) { return abs(a - b); }
inline Point translate(const Point &a, const Point &b) { return a + b; }
inline Point scale(const Point &c, double f, const Point &p) {
  return c + (p - c) * f;
}
inline Point rot(const Point &a, double b) {
  return Point(a.x * cos(b) - a.y * sin(b), a.x * sin(b) + a.y * cos(b));
}
inline Point perp(const Point &x) { return Point(-x.y, x.x); }
inline double dot(const Point &a, const Point &b) {
  return a.x * b.x + a.y * b.y;
}
inline bool isPerp(const Point &a, const Point &b) { return !sgn(dot(a, b)); }
inline double angle(const Point &a, const Point &b) {
  return acos(max(-1., min(1., dot(a, b) / abs(a) / abs(b))));
}
inline double cross(const Point &a, const Point &b) {
  return a.x * b.y - a.y * b.x;
}
inline double orient(const Point &a, const Point &b, const Point &c) {
  return cross(b - a, c - a);
}
struct Line {
  Point v;
  double c;
  Line(void);
  Line(const Point &_v, double _c) : v(_v), c(_c) {}
  Line(double _a, double _b, double _c) : v(_b, -_a), c(_c) {}
  Line(const Point &a, const Point &b) : v(b - a), c(cross(v, a)) {}
};
inline double side(const Line &a, const Point &b) {
  return cross(a.v, b) - a.c;
}
inline double dist(const Line &a, const Point &b) {
  return fabs(side(a, b)) / abs(a.v);
}
inline double sqDist(const Line &a, const Point &b) {
  return side(a, b) * side(a, b) / sqr(a.v);
}
inline Line perpThrough(const Line &a, const Point &b) {
  return Line(b, b + perp(a.v));
}
inline Line translate(const Line &a, const Point &b) {
  return Line(a.v, a.c + cross(a.v, b));
}
inline bool inter(const Line &a, const Line &b, Point &c) {
  double d = cross(a.v, b.v);
  if (!sgn(d)) return false;
  return c = (b.v * a.c - a.v * b.c) / d, true;
}
inline Point proj(const Line &a, const Point &b) {
  return b - perp(a.v) * side(a, b) / sqr(a.v);
}
inline Point refl(const Line &a, const Point &b) {
  return b - perp(a.v) * 2 * side(a, b) / sqr(a.v);
}
int main() {
  int x1, y1, x2, y2, n, a, b, c, cnt(0);
  scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
  Point p1(x1, y1), p2(x2, y2);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    Line l(a, b, -c);
    if (sgn(side(l, p1)) != sgn(side(l, p2))) ++cnt;
  }
  printf("%d\n", cnt);
  return 0;
}
