#include <bits/stdc++.h>
using namespace std;
struct pt {
  double x, y;
  pt(double x = 0, double y = 0) {
    this->x = x;
    this->y = y;
  }
};
pt ar[5], pvt;
pt mv(pt a, pt b) { return pt(b.x - a.x, b.y - a.y); }
double dp(pt a, pt b) { return a.x * b.x + a.y * b.y; }
double cp(pt a, pt b) { return a.x * b.y - a.y * b.x; }
double dis(pt a, pt b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
bool com(pt a, pt b) {
  double re = cp(mv(pvt, a), mv(pvt, b));
  if (re != 0) {
    return re > 0;
  }
  return dis(pvt, a) < dis(pvt, b);
}
int main() {
  int t, ta, i, j, k, ans = 0, n;
  double ax, by, cc;
  pt a, b, c, d, in, fin;
  cin >> in.x >> in.y;
  cin >> fin.x >> fin.y;
  cin >> n;
  while (n--) {
    cin >> ax >> by >> cc;
    double fst = (ax * in.x) + (by * in.y) + cc;
    double scd = (ax * fin.x) + (by * fin.y) + cc;
    if (fst * scd < 0.0) ans++;
  }
  cout << ans;
  return 0;
}
