#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long MX = 1e9;
const long long INF = 1e9;
void print_a(vector<int> v) {
  if (v.size()) cout << v[0];
  for (int i = 1; i < v.size(); ++i) cout << ' ' << v[i];
  cout << '\n';
}
vector<vector<int> > init_vvi(int n, int m, int val) {
  return vector<vector<int> >(n, vector<int>(m, val));
}
vector<vector<long long> > init_vvl(int n, int m, long long val) {
  return vector<vector<long long> >(n, vector<long long>(m, val));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  long long a[n + 1], b[n + 1], c[n + 1];
  for (int i = 1; i < n + 1; ++i) cin >> a[i] >> b[i] >> c[i];
  int ans = 0;
  long long s1, s2;
  for (int i = 1; i < n + 1; ++i) {
    s1 = (a[i] * x1) + (b[i] * y1) + c[i];
    s2 = (a[i] * x2) + (b[i] * y2) + c[i];
    if ((s1 >= 0 && s2 < 0) || (s1 < 0 && s2 >= 0)) ++ans;
  }
  cout << ans << '\n';
  return 0;
}
