#include <bits/stdc++.h>
using namespace std;
const long long N = 300 + 10;
long long sx, sy, ex, ey;
long long n;
struct code {
  long long a, b, c;
} p[N];
long long calca(long long i) {
  return (long long)p[i].a * sx + (long long)p[i].b * sy + (long long)p[i].c <
         0;
}
long long calcb(long long i) {
  return (long long)p[i].a * ex + (long long)p[i].b * ey + (long long)p[i].c <
         0;
}
int main() {
  long long ans = 0;
  scanf("%lld%lld%lld%lld", &sx, &sy, &ex, &ey);
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &p[i].a);
    scanf("%lld", &p[i].b);
    scanf("%lld", &p[i].c);
    if (calca(i) != calcb(i)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
