#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int x1, y1, x2, y2, res = 0;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    long long t1 = a * x1 + b * y1 + c;
    long long t2 = a * x2 + b * y2 + c;
    t1 = t1 > 0, t2 = t2 > 0;
    res += t1 != t2;
  }
  printf("%d\n", res);
  return 0;
}
