#include <bits/stdc++.h>
using namespace std;
long long n, a[305], b[305], c[305], mx, my, ux, uy;
long long f(int i, int x, int y) { return a[i] * x + b[i] * y + c[i]; }
bool does_intersect(int i) {
  if (f(i, mx, my) > 0 && f(i, ux, uy) < 0) return true;
  if (f(i, mx, my) < 0 && f(i, ux, uy) > 0) return true;
  return false;
}
int main() {
  cin >> mx >> my;
  cin >> ux >> uy;
  long long cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    if (does_intersect(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
