#include <bits/stdc++.h>
using namespace std;
struct pt {
  double x, y;
};
struct line {
  double a, b, c;
};
const double EPS = 1e-9;
double det(double a, double b, double c, double d) { return a * d - b * c; }
bool intersect(line m, line n, pt& res) {
  double zn = det(m.a, m.b, n.a, n.b);
  if (abs(zn) < EPS) return false;
  res.x = -det(m.c, m.b, n.c, n.b) / zn;
  res.y = -det(m.a, m.c, n.a, n.c) / zn;
  return true;
}
line toline(pt p1, pt p2) {
  line k;
  k.a = p1.y - p2.y;
  k.b = p2.x - p1.x;
  k.c = -k.a * p1.x - k.b * p1.y;
  return k;
}
bool isright(pt f, pt t, pt p) {
  int fx = min(f.x, t.x);
  int tx = max(f.x, t.x);
  int fy = min(f.y, t.y);
  int ty = max(f.y, t.y);
  return p.x >= fx && p.x <= tx && p.y >= fy && p.y <= ty;
}
line l[301];
int main() {
  ios::sync_with_stdio(true);
  int n;
  pt from, to;
  cin >> from.x >> from.y >> to.x >> to.y;
  line row = toline(from, to);
  cin >> n;
  pt t;
  int res = 0;
  for (int i = 0; i < n; i++) {
    cin >> l[i].a >> l[i].b >> l[i].c;
    if (intersect(l[i], row, t))
      if (isright(from, to, t)) res++;
  }
  cout << res << "\n";
  return 0;
}
