#include <bits/stdc++.h>
using namespace std;
long long modulo = 1e9 + 7;
long long mod1 = 998244353;
int main() {
  long long i, j, k = 0, a, b, c, x1, y1, x2, y2, p, q, r;
  cin >> x1 >> y1 >> x2 >> y2 >> j;
  for (i = 0; i < j; i++) {
    cin >> a >> b >> c;
    p = a * x1 + b * y1 + c;
    if (p > 0)
      p = 1;
    else
      p = -1;
    q = p * (a * x2 + b * y2 + c);
    if (q < 0) k++;
  }
  cout << k;
  return 0;
}
