#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
double cross(pair<double, double> u, pair<double, double> v) {
  return u.first * v.second - u.second * v.first;
}
int getSign(double a) {
  if (fabs(a) < EPS) {
    return 0;
  }
  return a > 0 ? 1 : -1;
}
pair<double, double> minuss(pair<double, double> b, pair<double, double> a) {
  return pair<double, double>(a.first - b.first, a.second - b.second);
}
int main() {
  pair<double, double> home, uni;
  cin >> home.first >> home.second;
  cin >> uni.first >> uni.second;
  int cnt = 0;
  int n;
  cin >> n;
  srand(time(NULL));
  for (int i = 0; i < n; ++i) {
    double a, b, c;
    cin >> a >> b >> c;
    pair<pair<double, double>, pair<double, double> > line;
    if (fabs(a) < EPS || fabs(b) < EPS) {
      if (fabs(a) < EPS) {
        double y = -c / b;
        if (y < max(home.second, uni.second) &&
            y > min(home.second, uni.second)) {
          cnt++;
        }
      } else {
        double x = -c / a;
        if (x < max(home.first, uni.first) && x > min(home.first, uni.first)) {
          cnt++;
        }
      }
    } else {
      {
        double random = (rand() % 100) + 1.123123;
        line.first = pair<double, double>(random, (-c - a * random) / b);
        random -= 50.656785;
        line.second = pair<double, double>(random, (-c - a * random) / b);
      }
      double sgn1 =
          cross(minuss(line.first, home), minuss(line.first, line.second));
      double sgn2 =
          cross(minuss(line.first, uni), minuss(line.first, line.second));
      assert(getSign(sgn1) != 0);
      assert(getSign(sgn2) != 0);
      if (getSign(sgn1) != getSign(sgn2)) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
