#include <bits/stdc++.h>
using namespace std;
long long x1, x2, y, y2, n, p, q, a, b, c;
int main() {
  int cnt = 0;
  cin >> x1 >> y;
  cin >> x2 >> y2;
  cin >> n;
  while (n--) {
    cin >> a >> b >> c;
    p = a * x1 + b * y + c;
    q = a * x2 + b * y2 + c;
    if ((p > 0 && q < 0) || (p < 0 && q > 0)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
