#include <bits/stdc++.h>
using namespace std;
void solve() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  int n, m = 0;
  double a, b, c, d, t;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> a >> b >> c;
    d = a * x1 + b * y1 + c;
    t = a * x2 + b * y2 + c;
    if (d * t < 0) m++;
  }
  cout << m << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}
