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