#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int Case = 1, n, m, x1, y1, x2, y2, a, b, c;
  char dump[2];
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    long long int X = (a * x1) + (b * y1) + c;
    long long int Y = (a * x2) + (b * y2) + c;
    if (X > 0 != Y > 0) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
