#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long inf64 = 1e18;
const long long MOD = inf + 7;
const long double PI = acos(-1.0);
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  ;
  long long x[2], y[2];
  cin >> x[0] >> y[0];
  cin >> x[1] >> y[1];
  long long ans = 0;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long t1 = a * x[0] + b * y[0] + c;
    long long t2 = a * x[1] + b * y[1] + c;
    long long c1 = t1 / abs(t1);
    long long c2 = t2 / abs(t2);
    if (c1 * c2 < 0) ans++;
  }
  cout << ans;
}
