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