#include <bits/stdc++.h>
using namespace std;
struct rec {
  double a, b, c;
};
rec d[100000];
int n;
double x11, y11, x2, y2;
double dis(double u, double v, double x, double y) {
  return (u - x) * (u - x) + (v - y) * (v - y);
}
void process() {
  cin >> x11 >> y11 >> x2 >> y2;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> d[i].a >> d[i].b >> d[i].c;
  double AB = dis(x11, y11, x2, y2);
  int res = 0;
  double u = x2 - x11, v = y2 - y11;
  for (int i = 1; i <= n; i++) {
    double c1 = x2 * v - u * y2;
    double c2 = -d[i].c;
    double a1 = v, b1 = -u, a2 = d[i].a, b2 = d[i].b;
    if (abs(a1 * b2 - a2 * b1) < 1e-12) continue;
    double detA = a1 * b2 - a2 * b1;
    double detA1 = c1 * b2 - c2 * b1;
    double detA2 = a1 * c2 - a2 * c1;
    double xx = detA1 / detA, yy = detA2 / detA;
    if ((xx - x11) * (xx - x2) <= 0 && (yy - y11) * (yy - y2) <= 0) ++res;
  }
  cout << res << endl;
}
int main() {
  process();
  return 0;
}
