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