#include <bits/stdc++.h>
using namespace std;
bool bet(double val, double a, double b) {
  return (val >= a && val <= b) || (val >= b && val <= a);
}
struct line {
  double a, b, c;
  long long x1, x2, y1, y2;
  line(long long _x1, long long _y1, long long _x2, long long _y2) {
    x1 = _x1, y1 = _y1, x2 = _x2, y2 = _y2;
    if (x1 == x2) {
      b = 0, a = 1, c = -x1;
    } else {
      b = 1;
      a = -(double)(y1 - y2) / (x1 - x2);
      c = -a * x1 - b * y1;
    }
  }
  line(int _a, int _b, int _c) {
    a = _a, b = _b, c = _c;
    if (b != 0) {
      a /= b;
      c /= b;
      b = 1;
    }
  }
  bool intersect(line l) {
    if (fabs(l.a - a) < 1e-6 && fabs(l.b - b) < 1e-6) return false;
    double xx, yy;
    xx = (l.c * b - c * l.b) / (l.b * a - l.a * b);
    if (l.b == 0)
      yy = -a * xx - c;
    else
      yy = -l.a * xx - l.c;
    return online(xx, yy);
  }
  bool online(double xx, double yy) {
    return bet(xx, x1, x2) && bet(yy, y1, y2);
  }
};
int main() {
  int sx, sy, ex, ey;
  scanf("%d %d %d %d", &sx, &sy, &ex, &ey);
  line seg(sx, sy, ex, ey);
  int n, a, b, c;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (seg.intersect(line(a, b, c))) cnt++;
  }
  cout << cnt;
}
