#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  long long int count = 0;
  for (int i = 0; i < n; i++) {
    long long int p = x1 * a[i] + y1 * b[i] + c[i];
    long long int q = x2 * a[i] + y2 * b[i] + c[i];
    if (p < 0 && q > 0) count++;
    if (q < 0 && p > 0) count++;
  }
  cout << count;
  return 0;
}
