#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x;
  long long y;
};
struct Vector {
  long long x;
  long long y;
  Vector(long long a, long long b) {
    x = a;
    y = b;
  }
  Vector(Point A, Point B) {
    x = B.x - A.x;
    y = B.y - A.y;
  }
};
int sign(long long a) {
  if (a > 0) return +1;
  if (a == 0) return 0;
  if (a < 0) return -1;
}
int crossproduct(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
int main() {
  cout.precision(7);
  cout << fixed;
  int n;
  Point A, B;
  cin >> A.x >> A.y >> B.x >> B.y;
  cin >> n;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int anw = 0;
  for (int i = 0; i < n; i++) {
    if (sign(a[i] * A.x + b[i] * A.y + c[i]) *
            sign(a[i] * B.x + b[i] * B.y + c[i]) <
        0)
      anw++;
  }
  cout << anw;
}
