#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
struct Point {
  int x, y;
  Point() {}
  Point(int x, int y) : x(x), y(y) {}
  void read() { scanf("%d%d", &x, &y); }
} A, B;
struct Segment {
  Point p, q;
  Segment() {}
  Segment(Point _p, Point _q) {
    p = _p;
    q = _q;
  }
} second;
struct Line {
  int a, b, c;
  Line() {}
  Line(int a, int b, int c) : a(a), b(b), c(c) {}
  void read() { scanf("%d%d%d", &a, &b, &c); }
  long long getValue(Point p) {
    return 1ll * a * p.x + 1ll * b * p.y + 1ll * c;
  }
  int sgn(Point p) {
    long long val = getValue(p);
    if (val > 0) return 1;
    return -1;
  }
  bool intersect(Segment second) {
    int s1 = sgn(second.p);
    int s2 = sgn(second.q);
    return s1 != s2;
  }
} a[100100];
int n;
int main() {
  A.read();
  B.read();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) a[i].read();
  int ans = 0;
  second = Segment(A, B);
  for (int i = 0; i < n; i++) {
    if (a[i].intersect(second)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
