#include <bits/stdc++.h>
using namespace std;
const double mod = 10e8 + 7;
void solve(void);
double x1, x2, z1, z2;
double a, b, c;
bool side() {
  double x = (-c) / a, y = (-c) / b;
  double n = a * x1 + b * z1 + c;
  double m = a * x2 + b * z2 + c;
  if ((n > 0 and m > 0) or (n < 0 and m < 0)) return false;
  return true;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
void solve() {
  cin >> x1;
  cin >> z1;
  cin >> x2 >> z2;
  double n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (side()) ans++;
  }
  cout << ans;
}
