#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
inline void amax(T &a, const T &b) {
  if (a < b) a = b;
}
long long HX, HY, UX, UY;
int N;
int sgn(long long n) {
  if (n < 0) return -1;
  if (n > 0) return 1;
  return 0;
}
int main() {
  scanf("%lld%lld%lld%lld", &HX, &HY, &UX, &UY);
  scanf("%d", &N);
  int cnt = 0;
  for (int $ = 0, $_len = (N); $ < $_len; $++) {
    long long A, B, C;
    scanf("%lld%lld%lld", &A, &B, &C);
    if (sgn(A * HX + B * HY + C) != sgn(A * UX + B * UY + C)) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}
