#include <bits/stdc++.h>
using namespace std;
int homeX, homeY;
int uniX, uniY;
int n;
long double CP(long double x1, long double y1, long double x2, long double y2) {
  return x1 * y2 - x2 * y1;
}
bool Intersects(int a, int b, int c) {
  long double X, Y;
  long double CP1, CP2;
  long double RX, RY;
  if (b == 0) {
    X = (long double)(-c) / (long double)(a);
    Y = 0.0;
    RX = X;
    RY = 1.0;
  } else {
    X = 0.0;
    Y = ((long double)(-c) - X * (long double)(a)) / (long double)(b);
    RX = 1.0;
    RY = ((long double)(-c) - RX * (long double)(a)) / (long double)(b);
  }
  CP1 = CP(RX - X, RY - Y, (long double)homeX - X, (long double)homeY - Y);
  CP2 = CP(RX - X, RY - Y, (long double)uniX - X, (long double)uniY - Y);
  if (CP1 < 0.0 && CP2 < 0.0)
    return false;
  else if (CP1 > 0.0 && CP2 > 0.0)
    return false;
  else
    return true;
}
int main() {
  int i;
  int ans = 0;
  int c;
  int lineA, lineB, lineC;
  scanf("%d %d", &homeX, &homeY);
  scanf("%d %d", &uniX, &uniY);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d", &lineA, &lineB, &lineC);
    if (Intersects(lineA, lineB, lineC)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
