#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int n;
long long a, b, c;
long long x1, yy, x2, y2;
int main() {
  while (~scanf("%I64d%I64d%I64d%I64d", &x1, &yy, &x2, &y2)) {
    scanf("%d", &n);
    int num = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%I64d%I64d%I64d", &a, &b, &c);
      if ((a * x1 + b * yy + c < 0 && a * x2 + b * y2 + c > 0) ||
          (a * x1 + b * yy + c > 0 && a * x2 + b * y2 + c < 0))
        num++;
    }
    printf("%d\n", num);
  }
  return 0;
}
