#include <bits/stdc++.h>
using namespace std;
long long power(long x, long n) {
  if (n == 0) return 1;
  if (n == 1) return x;
  long n2 = n / 2;
  long long po = power(x, n2);
  if (n % 2) return po * po * x;
  return po * po;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
class CCrazyTown {
 public:
  int sign(long long x) { return x > 0 ? 1 : -1; }
  void solve(std::istream &cin, std::ostream &cout) {
    long long X[2], Y[2], n, i, ans = 0, a, b, c;
    cin >> X[0] >> Y[0] >> X[1] >> Y[1];
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      if (sign(a * X[0] + b * Y[0] + c) != sign(a * X[1] + b * Y[1] + c)) ans++;
    }
    cout << ans << '\n';
  }
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  CCrazyTown solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
