#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, y1, x2, y2;
  scanf("%I64d%I64d%I64d%I64d", &x1, &y1, &x2, &y2);
  int n, ans = 0;
  scanf("%d", &n);
  while (n--) {
    long long a, b, c;
    scanf("%I64d%I64d%I64d", &a, &b, &c);
    long long s1 = a * x1 + b * y1 + c, s2 = a * x2 + b * y2 + c;
    if (s1 > 0 && s2 < 0 || s1 < 0 && s2 > 0) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
