#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a[2], b[2];
  cin >> a[0] >> a[1] >> b[0] >> b[1];
  long long int n;
  cin >> n;
  int s[n][3];
  long long int e = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i][0] >> s[i][1] >> s[i][2];
    long long int m = a[0] * s[i][0] + a[1] * s[i][1] + s[i][2];
    long long int n = b[0] * s[i][0] + b[1] * s[i][1] + s[i][2];
    if ((m >= 0 && n < 0) || (n >= 0 && m < 0)) {
      e++;
    }
  }
  cout << e << endl;
}
