#include <bits/stdc++.h>
using namespace std;
pair<int, int> cr[2];
long long n, cnt;
int main() {
  cin >> cr[0].first >> cr[0].second >> cr[1].first >> cr[1].second;
  cin >> n;
  long long a, b, c;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    long long p = a * cr[0].first + b * cr[0].second + c;
    long long q = a * cr[1].first + b * cr[1].second + c;
    if ((p > 0) ^ (q > 0)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
