#include <bits/stdc++.h>
using namespace std;
int sgn(long long x) { return x < 0 ? -1 : (x > 0 ? 1 : 0); }
int main() {
  int x1, y1, x2, y2, n, tot = 0;
  scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
  for (int i = 0, a, b, c; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    if (sgn(1ll * a * x1 + 1ll * b * y1 + c) *
            sgn(1ll * a * x2 + 1ll * b * y2 + c) <
        0)
      ++tot;
  }
  printf("%d\n", tot);
  return 0;
}
