#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void JAISHREERAM() {
  long long int n, i, j, ans = 0;
  double xa, xb, ya, yb, a, b, c, x, y;
  cin >> xa >> ya >> xb >> yb >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    bool f = 0;
    if (b != 0 && ya != yb) {
      bool g = 1;
      y = (-c - a * xa) / b;
      g &= ((y > ya) == (yb > ya));
      y = (-c - a * xb) / b;
      g &= ((y > yb) == (ya > yb));
      f |= g;
    }
    if (a != 0 && xa != xb) {
      bool g = 1;
      x = (-c - b * ya) / a;
      g &= ((x > xa) == (xb > xa));
      x = (-c - b * yb) / a;
      g &= ((x > xb) == (xa > xb));
      f |= g;
    }
    if (f) ans++;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int T = 1;
  for (int t = 1; t <= T; t++) {
    JAISHREERAM();
  }
  return 0;
}
