#include <bits/stdc++.h>
using namespace std;
struct Point {
  double x, y;
};
struct Line {
  double a, b, c;
};
int main() {
  Point start, dest;
  cin >> start.x >> start.y >> dest.x >> dest.y;
  if (start.x > dest.x) swap(start, dest);
  Line line;
  line.a = start.y - dest.y;
  line.b = dest.x - start.x;
  line.c = -(line.a * start.x + line.b * start.y);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    Line read;
    cin >> read.a >> read.b >> read.c;
    double zn = line.a * read.b - read.a * line.b;
    if (zn == 0) continue;
    double chx = line.b * read.c - read.b * line.c,
           chy = line.c * read.a - line.a * read.c;
    double x0 = chx / zn, y0 = chy / zn;
    if (start.x != dest.x && start.x < x0 && x0 < dest.x ||
        start.x == dest.x && start.x == x0 && x0 == dest.x)
      if (start.y < dest.y && start.y < y0 && y0 < dest.y ||
          start.y > dest.y && dest.y < y0 && y0 < start.y ||
          start.y == dest.y && dest.y == y0 && y0 == start.y)
        ans++;
  }
  cout << ans << endl;
  return 0;
}
