#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 5;
int n;
long long hx, hy;
long long ux, uy;
struct line {
  long long x1, y1;
  long long x2, y2;
  line(long long _x1, long long _y1, long long _x2, long long _y2) {
    x1 = _x1;
    y1 = _y1;
    x2 = _x2;
    y2 = _y2;
  }
};
vector<line> lines;
void get_line(long long a, long long b, long long c) {
  long long x1, y1;
  long long x2, y2;
  if (b == 0) {
    x1 = -c / a;
    x2 = -c / a;
    y1 = -1e7;
    y2 = 1e7;
  }
  if (a == 0) {
    y1 = -c / b;
    y2 = -c / b;
    x1 = -1e7;
    x2 = 1e7;
  }
  if (a != 0 && b != 0) {
    x1 = -1e7;
    x2 = 1e7;
    y1 = (-a * x1 - c) / b;
    y2 = (-a * x2 - c) / b;
  }
  lines.push_back(line(x1, y1, x2, y2));
}
struct point {
  long long x;
  long long y;
  point() {
    x = 0;
    y = 0;
  }
  point(long long _x, long long _y) {
    x = _x;
    y = _y;
  }
};
int orientation(point a, point b, point c) {
  long long clockwise = (b.y - a.y) * (c.x - b.x) - (c.y - b.y) * (b.x - a.x);
  if (clockwise > 0) return 1;
  if (clockwise == 0) return 0;
  if (clockwise < 0) return -1;
}
bool do_intersect(line a, line b) {
  point a1, a2;
  point b1, b2;
  a1 = point(a.x1, a.y1);
  a2 = point(a.x2, a.y2);
  b1 = point(b.x1, b.y1);
  b2 = point(b.x2, b.y2);
  if ((orientation(a1, a2, b1) != orientation(a1, a2, b2)) &&
      (orientation(b1, b2, a1) != orientation(b1, b2, a2)))
    return true;
  return false;
}
int ans;
int main() {
  int i;
  long long a, b, c;
  cin >> hx >> hy;
  cin >> ux >> uy;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d%I64d", &a, &b, &c);
    get_line(a, b, c);
  }
  line road = line(hx, hy, ux, uy);
  for (i = 0; i < lines.size(); i++) {
    if (do_intersect(road, lines[i])) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
