#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long x1, y1;
  long long x2, y2;
  scanf("%lld%lld", &x1, &y1);
  scanf("%lld%lld", &x2, &y2);
  int n;
  scanf("%d", &n);
  long long a, b, c;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &a, &b, &c);
    long long xx1 = x1 * a;
    long long xx2 = x2 * a;
    if ((xx1 < -c - y1 * b && xx2 > -c - y2 * b) ||
        (xx1 > -c - y1 * b && xx2 < -c - y2 * b))
      ans++;
  }
  cout << ans;
  return 0;
}
