#include <bits/stdc++.h>
using namespace std;
int main() {
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  double x[n], y[n], c[n];
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
  for (int i = 0; i < n; i++) {
    double a, b;
    a = x[i] * x1 + y[i] * y1 + c[i];
    b = x[i] * x2 + y[i] * y2 + c[i];
    if (a * b < 0) ans++;
  }
  cout << ans;
  return 0;
}
