#include <bits/stdc++.h>
using namespace std;
const static double EPS = 1e-7;
inline bool eps_eq(double a, double b) {
  return (a > b ? a - b : b - a) <= EPS;
}
inline bool eps_le(double a, double b) { return a <= b || eps_eq(a, b); }
struct Line {
  double a, b, c;
};
struct Point {
  double x, y;
};
struct Segment {
  Point p, q;
  Line line;
};
inline bool intersection(const Line &p, const Line &q, Point &out) {
  double det = p.a * q.b - p.b * q.a;
  if (eps_eq(det, 0)) return false;
  double x = p.c * q.b - p.b * q.c;
  double y = p.a * q.c - p.c * q.a;
  out.x = -x / det;
  out.y = -y / det;
  return true;
}
inline double sqr(double x) { return x * x; }
inline double dist(const Point &p, const Point &q) {
  return sqrt(sqr(p.x - q.x) + sqr(p.y - q.y));
}
inline bool sl_int(const Line &l, const Segment &s) {
  Point p;
  if (!intersection(l, s.line, p)) return false;
  double len = dist(s.p, s.q);
  return eps_le(dist(p, s.p), len) && eps_le(dist(p, s.q), len);
}
inline Segment tosegment(const Point &p, const Point &q) {
  Segment s;
  s.p = p;
  s.q = q;
  s.line.a = p.y - q.y;
  s.line.b = q.x - p.x;
  s.line.c = p.x * q.y - p.y * q.x;
  return s;
}
int main() {
  Point s, t;
  cin >> s.x >> s.y >> t.x >> t.y;
  int n;
  cin >> n;
  vector<Line> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].a >> v[i].b >> v[i].c;
  }
  Segment seg = tosegment(s, t);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (sl_int(v[i], seg)) ++ans;
  }
  cout << ans;
  return 0;
}
