#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
struct Node {
  long long x, y;
} p1, p2;
int n;
int main() {
  scanf("%I64d%I64d%I64d%I64d", &p1.x, &p1.y, &p2.x, &p2.y);
  scanf("%d", &n);
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    long long a, b, c;
    scanf("%I64d%I64d%I64d", &a, &b, &c);
    long long t1 = (a * p1.x + b * p1.y + c);
    long long t2 = (a * p2.x + b * p2.y + c);
    if ((t1 > 0 && t2 < 0) || (t1 < 0 && t2 > 0)) cnt++;
  }
  printf("%I64d\n", cnt);
  return 0;
}
