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