#include <bits/stdc++.h>
using namespace std;
const int MAXN = 305;
struct Point {
  long long x, y;
} h, u;
int n;
void solve() {
  cin >> h.x >> h.y;
  cin >> u.x >> u.y;
  cin >> n;
  int res = 0;
  long long t1, t2;
  long long a, b, c;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    t1 = a * h.x + b * h.y + c;
    t2 = a * u.x + b * u.y + c;
    if ((t1 < 0 && t2 < 0) || (t1 > 0 && t2 > 0)) continue;
    res++;
  }
  cout << res << endl;
}
int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
