#include <bits/stdc++.h>
using namespace std;
int main() {
  pair<int, int> u, v;
  int n, ans = 0;
  long long a, b, c, p, q;
  scanf("%d%d%d%d", &u.first, &u.second, &v.first, &v.second);
  scanf("%d", &n);
  while (n--) {
    scanf("%lld%lld%lld", &a, &b, &c);
    p = a * u.first + b * u.second + c;
    q = a * v.first + b * v.second + c;
    if ((p > 0 && q < 0) || (p < 0 && q > 0)) ++ans;
  }
  printf("%d\n", ans);
}
