#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 17;
const long long LINF = 0x3C3C3C3C3C3C3C3Cll;
const int INF = LINF;
int main() {
  long long x1, y1;
  long long x2, y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  int n;
  cin >> n;
  int res = 0;
  while (n--) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long p1 = a * x1 + b * y1 + c;
    long long p2 = a * x2 + b * y2 + c;
    if ((p1 > 0 && p2 < 0) || (p1 < 0 && p2 > 0)) {
      res++;
    }
  }
  cout << res << '\n';
  return 0;
}
