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