#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
struct Poi {
  double x, y;
  Poi() {}
  Poi(double x, double y) : x(x), y(y) {}
  Poi operator-(const Poi& rhs) const { return Poi(x - rhs.x, y - rhs.y); }
};
struct Line {
  Poi p;
  Poi v;
  Line() {}
  Line(const Poi& p, const Poi& v) : p(p), v(v) {}
};
Line toline(double a, double b, double c) {
  Poi v(b, -a);
  Poi p;
  if (fabs(a) > fabs(b)) {
    p = Poi(-c / a, 0);
  } else {
    p = Poi(0, -c / b);
  }
  return Line(p, v);
}
inline double cross(const Poi& a, const Poi& b) {
  return a.x * b.y - a.y * b.x;
}
inline bool onleft(const Poi& p, const Line& L) {
  return cross(L.v, p - L.p) > 0;
}
inline Poi gPoi() {
  int x, y;
  scanf("%d%d", &x, &y);
  return Poi(x, y);
}
int n;
int main() {
  Poi P = gPoi(), Q = gPoi();
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0, a, b, c; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    Line L = toline(a, b, c);
    if (onleft(P, L) != onleft(Q, L)) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
