#include <bits/stdc++.h>
using namespace std;
const int maxn = 301;
const double eps = 1e-8;
struct Segment {
  double a, b, c;
} seg[maxn], sta;
struct Point {
  double x, y;
} you, uni;
bool calcross(Segment l, Segment sa, Point &ans) {
  double delta = l.a * sa.b - l.b * sa.a;
  if (abs(delta) < eps) return false;
  ans.x = (-l.c * sa.b) - (-sa.c * l.b);
  ans.y = l.a * (-sa.c) - sa.a * (-l.c);
  ans.x /= delta;
  ans.y /= delta;
  return true;
}
int main() {
  int i, n, con = 0;
  double x, y;
  Point ans;
  scanf("%lf %lf", &you.x, &you.y);
  scanf("%lf %lf", &uni.x, &uni.y);
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf %lf %lf", &seg[i].a, &seg[i].b, &seg[i].c);
  }
  if (you.x > uni.x) swap(you, uni);
  x = uni.x - you.x;
  y = uni.y - you.y;
  sta.a = -y;
  sta.b = x;
  sta.c = you.x * y - you.y * x;
  for (i = 0; i < n; i++)
    if (calcross(sta, seg[i], ans)) {
      if ((ans.x - you.x) * (ans.x - uni.x) < 0 ||
          (ans.y - you.y) * (ans.y - uni.y) < 0)
        con++;
    }
  printf("%d\n", con);
  return 0;
}
