#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double pi = acos(-1.0);
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
struct point_i {
  int x, y;
  point_i() { x = y = 0; };
  point_i(int x_, int y_) : x(x_), y(y_) {}
};
struct line {
  double a, b, c;
};
struct point {
  double x, y;
  point() { x = y = 0.0; };
  point(double x_, double y_) : x(x_), y(y_) {}
  bool operator<(point other) const {
    if (fabs(x - other.x) < EPS) return y < other.y;
    return x < other.x;
  }
  bool operator==(point other) const {
    return fabs(x - other.x) < EPS && fabs(y - other.y) < EPS;
  }
};
double dist(point p1, point p2) { return hypot(p1.x - p2.x, p1.y - p2.y); }
void pointsToLine(point p1, point p2, line &l) {
  if (fabs(p1.x - p2.x) < EPS) {
    l.a = 1.0, l.b = 0.0, l.c = -p1.x;
  } else {
    l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x);
    l.b = 1.0;
    l.c = -(double)(l.a * p1.x) - p1.y;
  }
}
bool areParallel(line l1, line l2) {
  return (fabs(l1.a - l2.a) < EPS && fabs(l1.b - l2.b) < EPS);
}
bool areIntersect(line l1, line l2, point &p) {
  if (areParallel(l1, l2)) return false;
  p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
  if (fabs(l1.b) > EPS)
    p.y = -(l1.a * p.x + l1.c);
  else
    p.y = -(l2.a * p.x + l2.c);
  return true;
}
bool between(point p1, point p2, point p) {
  return (p.x + EPS >= min(p1.x, p2.x) && p.x <= max(p1.x, p2.x) + EPS &&
          p.y + EPS >= min(p1.y, p2.y) && p.y <= max(p1.y, p2.y) + EPS);
}
int main() {
  point p1, p2;
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  line l1;
  pointsToLine(p1, p2, l1);
  int n;
  cin >> n;
  line a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i].a >> a[i].b >> a[i].c;
    point f, s;
    if (!a[i].a) {
      f.y = (-a[i].a * 1 - a[i].c) / a[i].b;
      f.x = 1;
      s.y = (-a[i].a * 2 - a[i].c) / a[i].b;
      s.x = 2;
    } else {
      f.x = (-a[i].b * 1 - a[i].c) / a[i].a;
      f.y = 1;
      s.x = (-a[i].b * 2 - a[i].c) / a[i].a;
      s.y = 2;
    }
    pointsToLine(f, s, a[i]);
  }
  int ans = 0;
  point p;
  for (int i = 0; i < n; ++i) {
    if (areIntersect(l1, a[i], p) && between(p1, p2, p)) {
      ++ans;
    }
  }
  cout << ans << endl;
}
