#include <bits/stdc++.h>
using namespace std;
int x, y, X, Y;
int a0, b0, c0;
bool ok() {
  if (b0 == 0) {
    if ((long double)-c0 / a0 >= min(x, X) &&
        (long double)-c0 / a0 <= max(x, X))
      return true;
    return false;
  }
  long double k = (long double)-a0 / b0;
  long double b = (long double)-c0 / b0;
  if ((long double)(k * x + b - y) * (k * X + b - Y) <= 0) return true;
  return false;
}
int give = 0;
int main() {
  cin >> x >> y >> X >> Y;
  int T;
  cin >> T;
  while (T--) {
    scanf("%d%d%d", &a0, &b0, &c0);
    give += ok();
  }
  cout << give;
  return 0;
}
