#include <bits/stdc++.h>
using namespace std;
long long x1, yp, x2, y2, aa, bb, cc;
int n;
long long a, b, c;
int ans = 0;
int main() {
  cin >> x1 >> yp >> x2 >> y2 >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b >> c;
    long long x = a * x1 + b * yp + c, y = a * x2 + b * y2 + c;
    if (x > 0 && y < 0 || x < 0 && y > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
