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