#include <bits/stdc++.h>
using namespace std;
long long aa;
int main() {
  int x1, y1, x2, y2;
  int n;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  scanf("%d", &n);
  int ans = 0;
  while (n--) {
    long long a, b, c;
    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\n", ans);
  return 0;
}
