#include <bits/stdc++.h>
using namespace std;
int sgn(long long v) { return v > 0 ? 1 : 0; }
int main(void) {
  long long p, q, r, s;
  cin >> p >> q >> r >> s;
  int n;
  int res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    long long temp1 = (a * p + b * q + c);
    long long temp2 = a * r + b * s + c;
    res = (sgn(temp1) == sgn(temp2)) ? res : res + 1;
  }
  cout << res << endl;
  return 0;
}
