#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int main() {
  int n, i, ans = 0;
  long long r1, r2, c1, c2, t1, t2;
  cin >> r1 >> c1 >> r2 >> c2;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a >> b >> c;
    t1 = (r1 * a + c1 * b + c);
    t2 = (r2 * a + c2 * b + c);
    if (t1 > 0 && t2 < 0 || t1 < 0 && t2 > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
