#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double Pi = 3.1415926535897932;
const int NMAX = 300 + 5;
const int MMAX = 100000 + 5;
const int INF = 1000000000;
const int BASE = 1000000007;
template <typename T>
inline T abs(const T a) {
  if (a < 0) return -a;
  return a;
}
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
int sgn(long long x) {
  if (x > 0) return 1;
  if (0 == x) return 0;
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  int x1, y1;
  int x2, y2;
  int n;
  int i;
  int a, b, c;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> n;
  int res = 0;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (sgn(a * 1ll * x1 + b * 1ll * y1 + c) !=
        sgn(a * 1ll * x2 + b * 1ll * y2 + c))
      res++;
  }
  cout << res << endl;
  return 0;
}
