#include <bits/stdc++.h>
using namespace std;
long long abss(long long n) {
  if (n < 0) n *= -1;
  return n;
}
int main() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  int ans = 0;
  while (n--) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long p = (x1 * a) + (y1 * b) + c;
    long long q = (x2 * a) + (y2 * b) + c;
    p = p / abss(p);
    q = q / abss(q);
    if (p * q < 0) ans++;
  }
  cout << ans << "\n";
}
