#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
template <class T>
inline bool read(T &n) {
  T x = 0, tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
  if (c == EOF) return false;
  if (c == '-') c = getchar(), tmp = -1;
  while (c >= '0' && c <= '9') x *= 10, x += (c - '0'), c = getchar();
  n = x * tmp;
  return true;
}
template <class T>
inline void write(T n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  int len = 0, data[20];
  while (n) {
    data[len++] = n % 10;
    n /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
}
int main() {
  long long x, y, a, b, c;
  long long xx, yy, n, ans = 0;
  read(x), read(y), read(xx), read(yy);
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a), read(b), read(c);
    bool t = a * x + b * y + c > 0;
    bool tt = a * xx + b * yy + c > 0;
    if (tt != t) ans++;
  }
  write(ans), putchar('\n');
  return 0;
}
