#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5, INF = 0x3f3f3f3f;
int main() {
  double x0, y0, x1, x2, y1, y2, a1, a2, b1, b2, c1, c2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
  if (x1 == x2 && y1 == y2) {
    printf("0\n");
    return 0;
  }
  if (x1 == x2) {
    a1 = 1, b1 = 0, c1 = (-1 * x1);
  } else if (y1 == y2) {
    a1 = 0, b1 = 1, c1 = (-1 * y1);
  } else {
    a1 = 1, b1 = (x2 - x1) / (y1 - y2);
    c1 = (-1 * x1) - b1 * y1;
  }
  double b_x1 = min(x1, x2), b_x2 = max(x1, x2);
  int n, i, j, ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf%lf%lf", &a2, &b2, &c2);
    if (a2 == 0) {
      y0 = -1 * c2 / b2;
      if (y0 >= min(y1, y2) && y0 <= max(y1, y2)) ans++;
    } else if (b2 == 0) {
      x0 = -1 * c2 / a2;
      if (x0 >= b_x1 && x0 <= b_x2) ans++;
    } else if (a1 == 0) {
      x0 = -1 * (b2 * y1 + c2) / a2;
      if (x0 >= b_x1 && x0 <= b_x2) ans++;
      continue;
    } else if (b1 == 0) {
      y0 = -1 * (a2 * x1 + c2) / b2;
      if (y0 >= min(y1, y2) && y0 <= max(y1, y2)) ans++;
    } else {
      x0 = -1 * (c1 * b2 - c2 * b1) / (a1 * b2 - a2 * b1);
      if (x0 >= b_x1 && x0 <= b_x2) ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
