#include <bits/stdc++.h>
using namespace std;
const int MX = 7 + 1e4;
long double x, y, xx, yy;
long double p, q, u, h;
bool isit(long double a, long double b, long double c) {
  if (a == 0) {
    long double ty = -1 * c / b;
    return (ty < u && ty > h);
  }
  if (b == 0) {
    long double tx = (-1 * c) / (a);
    return (tx < p && tx > q);
  }
  long double ty, tx, ty1, tx1;
  bool ss = 0;
  return (a * x + b * y + c > 0) ^ (a * xx + b * yy + c > 0);
}
int main() {
  cin >> x >> y >> xx >> yy;
  p = max(x, xx);
  q = min(x, xx);
  u = max(y, yy);
  h = min(y, yy);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long double a, b, c;
    cin >> a >> b >> c;
    ans += isit(a, b, c);
  }
  cout << ans;
  return 0;
}
