#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T x, T y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
string qw = "abcdefghijklmnopqrstuvwxyz";
long long int ncrmodp(int n, int r, int p) {
  long long int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
long long int power(long long int x, long long int y, long long int P) {
  long long int res = 1;
  x = x % P;
  while (y > 0) {
    if (y & 1) res = (res * x) % P;
    y = y >> 1;
    x = (x * x) % P;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int hx, hy, ox, oy;
  cin >> hx >> hy >> ox >> oy;
  long long int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    long long int t1 = a * hx + b * hy + c;
    long long int t2 = a * ox + b * oy + c;
    if (t1 < 0 && t2 > 0) {
      ans++;
    } else if (t1 > 0 && t2 < 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
