#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by;
int N;
bool above(long long a, long long b, long long c, long long x, long long y) {
  if (b == 0) return x * a > -c;
  return a * x + b * y + c > 0;
}
int main() {
  cin >> ax >> ay >> bx >> by;
  int ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (a < 0) {
      a *= -1;
      b *= -1;
      c *= -1;
    }
    if (above(a, b, c, ax, ay) != above(a, b, c, bx, by)) ans++;
  }
  cout << ans << endl;
}
