#include <bits/stdc++.h>
using namespace std;
template <class T>
class POINT {
 public:
  T P[2];
  POINT() {}
  POINT(T x, T y) { P[0] = x, P[1] = y; }
  T operator*(const POINT &a) {
    return a.P[0] * this->P[0] + a.P[1] * this->P[1];
  }
  POINT operator-(const POINT &b) {
    return POINT(this->P[0] - b.P[0], this->P[1] - b.P[1]);
  }
  T operator^(const POINT &b) {
    return this->P[0] * b.P[1] - this->P[1] * b.P[0];
  }
};
int ccw(POINT<double> a, POINT<double> b, POINT<double> c) {
  double foo = ((b - a) ^ (c - a));
  return foo > 0 ? 1 : (foo < 0 ? -1 : 0);
}
int main() {
  POINT<double> P1, P2;
  int x1, x2, y1, y2;
  scanf("%d", &x1);
  scanf("%d", &y1);
  scanf("%d", &x2);
  scanf("%d", &y2);
  int n;
  scanf("%d", &n);
  P1 = POINT<double>(x1, y1), P2 = POINT<double>(x2, y2);
  int a, b, c;
  int res = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    POINT<double> L1, L2;
    if (a == 0) {
      L1.P[1] = L2.P[1] = -c / double(b);
      L1.P[0] = 1;
      L2.P[0] = 2;
    }
    if (b == 0) {
      L1.P[0] = L2.P[0] = -c / double(a);
      L1.P[1] = 1;
      L2.P[1] = 2;
    }
    if (a != 0 && b != 0) {
      if (c != 0) {
        L1.P[0] = -c / double(a);
        L1.P[1] = 0;
        L2.P[0] = 0;
        L2.P[1] = -c / double(b);
      } else {
        L1.P[0] = -c / double(a) - b;
        L1.P[1] = 1;
        L2.P[0] = 0;
        L2.P[1] = -c / double(b);
      }
    }
    res += (ccw(L1, L2, P1) != ccw(L1, L2, P2));
  }
  printf("%d\n", res);
}
