#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long x1, y1;
  long long x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long n;
  cin >> n;
  long long ans = 0;
  long long a1[1000], b1[1000], c1[1000];
  for (long long i = 0; i < n; i++) {
    cin >> a1[i] >> b1[i] >> c1[i];
    c1[i] *= -1;
  }
  long long a2, b2, c2;
  a2 = y2 - y1;
  b2 = x1 - x2;
  c2 = a2 * x1 + b2 * y1;
  for (long long i = 0; i < n; i++) {
    long double det = a1[i] * b2 - a2 * b1[i];
    if (det == 0) {
    } else {
      long double x = (b2 * c1[i] - b1[i] * c2) / det;
      long double y = (a1[i] * c2 - a2 * c1[i]) / det;
      if (x >= min(x1, x2) && x <= max(x1, x2) && y >= min(y1, y2) &&
          y <= max(y1, y2))
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
