#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.);
const long long MOD = 1000000007;
int sign(long long x) { return x < 0 ? -1 : x > 0; }
int main() {
  int i, j, k, _T;
  long long x1, y1, x2, y2;
  while (cin >> x1 >> y1 >> x2 >> y2) {
    int n;
    scanf("%d", &n);
    int cnt = 0;
    while (n--) {
      long long a, b, c;
      cin >> a >> b >> c;
      int f1 = sign(a * x1 + b * y1 + c);
      int f2 = sign(a * x2 + b * y2 + c);
      if (f1 != f2) cnt++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
