#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 10;
const int K = 11;
const int MOD = int(1e9) + 7;
const int INF = int(2e9) + 5;
const long long INF64 = 1e18;
void Solve() {
  long long x1, y1;
  cin >> x1 >> y1;
  long long x2, y2;
  cin >> x2 >> y2;
  int cnt = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long f = a * x1 + b * y1 + c;
    long long s = a * x2 + b * y2 + c;
    if ((f > 0 && s < 0) || (f < 0 && s > 0)) cnt++;
  }
  cout << cnt << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    Solve();
  }
  return 0;
}
