#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  long long a, b, c;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    long long home = x1 * a + b * y1 + c;
    long long varsity = x2 * a + b * y2 + c;
    if ((home > 0 && varsity < 0) or (home < 0 && varsity > 0)) {
      ans++;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
