#include <bits/stdc++.h>
using namespace std;
long long a[301], b[301], c[301];
long long xh, xu, yh, yu, n;
long long sum;
int main() {
  cin >> xh >> yh;
  cin >> xu >> yu;
  cin >> n;
  sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    if ((a[i] * xh + b[i] * yh + c[i] > 0) &&
        (a[i] * xu + b[i] * yu + c[i]) < 0) {
      sum++;
    } else if ((a[i] * xh + b[i] * yh + c[i] < 0) &&
               (a[i] * xu + b[i] * yu + c[i]) > 0) {
      sum++;
    }
  }
  cout << sum << endl;
}
