#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int n;
long long X1, Y1, X2, Y2;
long long sign(long long a) {
  if (a > 0) return 1;
  if (a < 0) return -1;
  return 0;
}
int main() {
  cin >> X1 >> Y1 >> X2 >> Y2;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    if (sign(a * X1 + b * Y1 + c) != sign(a * X2 + b * Y2 + c)) ans++;
  }
  cout << ans;
  return 0;
}
