#include <bits/stdc++.h>
using namespace std;
template <class T>
void makemax(T& a, const T& b) {
  if (a < b) a = b;
}
template <class T>
void makemin(T& a, const T& b) {
  if (a > b) a = b;
}
int main() {
  int xh, yh, xu, yu;
  scanf("%d%d", &xh, &yh);
  scanf("%d%d", &xu, &yu);
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = (0); i < (n); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    long long d1 = ((long long)a * xh + (long long)b * yh + c);
    long long d2 = ((long long)a * xu + (long long)b * yu + c);
    if (d1 < 0 && d2 > 0 || d1 > 0 && d2 < 0) ++cnt;
  }
  printf("%d\n", cnt);
  return 0;
}
