#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int s(long long x) {
  if (x > 0) return 1;
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, x1, y1, x2, y2, a, b, c;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> n;
  int ans = 0;
  while (n--) {
    cin >> a >> b >> c;
    if (s(x1 * a + y1 * b + c) != s(x2 * a + y2 * b + c)) ans++;
  }
  cout << ans;
  return 0;
}
