#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, x2, y1, y2;
  long long i, n, a, b, c;
  long long sum1, sum2, cnt = 0;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c;
    sum1 = a * x1 + b * y1 + c;
    sum2 = a * x2 + b * y2 + c;
    if ((sum1 > 0 && sum2 < 0) || (sum1 < 0 && sum2 > 0)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
