#include <bits/stdc++.h>
int a, b, c, n, x[2], y[2], ans;
bool f(int i) { return 1LL * a * x[i] + 1LL * b * y[i] + c > 0; }
int main() {
  scanf("%d%d%d%d%d", x, y, x + 1, y + 1, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (f(0) != f(1)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
