#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
;
const double pi = acos(-1.0);
template <class T>
inline T sqr(T a) {
  return a * a;
}
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
int ans, m;
int main() {
  long long x1, y1, x2, y2;
  scanf("%lld%lld", &x1, &y1);
  scanf("%lld%lld", &x2, &y2);
  scanf("%d", &m);
  for (int i = (1); i <= (m); ++i) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    long long p = x1 * a + y1 * b + c;
    long long q = x2 * a + y2 * b + c;
    if (p > 0 && q < 0 || p < 0 && q > 0) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
