#include <bits/stdc++.h>
using namespace std;
int N, xh, yh, xu, yu;
int A[303], B[303], C[303];
set<vector<bool> > s;
double eval(int i, double x, double y) { return A[i] * x + B[i] * y + C[i]; }
bool test(int i, vector<bool> &v) {
  double ax, ay, bx, by;
  if (B[i] == 0) {
    ax = bx = -C[i] / A[i];
    ay = -2000000000;
    by = 2000000000;
  } else {
    ax = -2000000000;
    bx = 2000000000;
    ay = (-C[i] - A[i] * ax) / B[i];
    by = (-C[i] - A[i] * bx) / B[i];
  }
  for (int j = 0; j < N; j++) {
    if (i == j) continue;
    long long tt = eval(i, ax, ay);
    if (tt > 0 && v[j]) {
      double det = A[i] * B[j] - A[j] * B[i];
      ax = (B[j] * C[i] - B[i] * C[j]) / det;
      ay = (A[i] * C[j] - A[j] * C[i]) / det;
    } else if (tt < 0 && v[j]) {
      double det = A[i] * B[j] - A[j] * B[i];
      ax = (B[j] * C[i] - B[i] * C[j]) / det;
      ay = (A[i] * C[j] - A[j] * C[i]) / det;
    }
    tt = eval(i, bx, by);
    if (tt > 0 && v[j]) {
      double det = A[i] * B[j] - A[j] * B[i];
      bx = (B[j] * C[i] - B[i] * C[j]) / det;
      by = (A[i] * C[j] - A[j] * C[i]) / det;
    } else if (tt < 0 && v[j]) {
      double det = A[i] * B[j] - A[j] * B[i];
      bx = (B[j] * C[i] - B[i] * C[j]) / det;
      by = (A[i] * C[j] - A[j] * C[i]) / det;
    }
  }
  return ax < bx || (ax == bx && ay < by);
}
int main() {
  cin >> xh >> yh >> xu >> yu;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i] >> C[i];
  vector<bool> v, e;
  int m = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (eval(i, xh, yh) > 0)
      v.push_back(1);
    else
      v.push_back(0);
    if (eval(i, xu, yu) > 0)
      e.push_back(1);
    else
      e.push_back(0);
    if (v[i] != e[i]) ans++;
  }
  cout << ans << endl;
}
