#include <bits/stdc++.h>
struct Point {
  long long int x, y;
  Point(long long int x = 0, long long int y = 0) : x(x), y(y) {}
  void input() { scanf("%I64d%I64d", &x, &y); }
};
struct Line {
  long long int a, b, c;
  Line(long long int a = 0, long long int b = 0, long long int c = 0)
      : a(a), b(b), c(c) {}
  void input() {
    scanf("%I64d%I64d%I64d", &a, &b, &c);
    if (a < 0) a = -a, b = -b, c = -c;
  }
  bool postive(Point P) { return a * P.x + b * P.y + c > 0; }
};
int main() {
  Point Home, University;
  Home.input();
  University.input();
  int N;
  scanf("%d", &N);
  int Ans = 0;
  Line L;
  while (N--) {
    L.input();
    if (L.postive(Home) != L.postive(University)) {
      Ans++;
    }
  }
  printf("%d\n", Ans);
}
