#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const long long INF = 1e9 + 9;
const long long MOD = 1000000007;
long long a[500], b[500], c[500];
long long x1_, y1_;
long long x2_, y2_;
bool intersect(int i) {
  long long q, w;
  q = a[i] * x1_ + b[i] * y1_ + c[i];
  w = a[i] * x2_ + b[i] * y2_ + c[i];
  if (q < 0 && w > 0) return true;
  if (q > 0 && w < 0) return true;
  return false;
}
int main() {
  cin >> x1_ >> y1_ >> x2_ >> y2_;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (intersect(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}
