#include <bits/stdc++.h>
int main() {
  long long x1, x2, y1, y2, n;
  scanf("%lld%lld", &x1, &y1);
  scanf("%lld%lld", &x2, &y2);
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    long long s1 = a * x1 + b * y1 + c;
    long long s2 = a * x2 + b * y2 + c;
    if ((s1 > 0 && s2 < 0) || (s1 < 0 && s2 > 0)) ans++;
  }
  printf("%lld", ans);
  return 0;
}
