#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, y1, x2, y2, n;
  scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    double a, b, c;
    scanf("%lf%lf%lf", &a, &b, &c);
    double t1 = a * x1 + b * y1 + c;
    double t2 = a * x2 + b * y2 + c;
    if (t1 * t2 < 0) cnt++;
  }
  printf("%d\n", cnt);
}
