#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 1005;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long x1, x2, y1, y2, n, ans = 0;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (((a * x1 + b * y1 + c) > 0 && (a * x2 + b * y2 + c) < 0) ||
        ((a * x1 + b * y1 + c) < 0 && (a * x2 + b * y2 + c) > 0))
      ans++;
  }
  cout << ans << '\n';
  return 0;
}
