#include <bits/stdc++.h>
using namespace std;
long long x1, aasdfasdfasdf, x2, y2, n;
long long a, b, c, v1, v2;
long long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> x1 >> aasdfasdfasdf;
  cin >> x2 >> y2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    v1 = a * x1 + b * aasdfasdfasdf + c;
    v2 = a * x2 + b * y2 + c;
    if (v1 > 0 && v2 < 0) ++ans;
    if (v1 < 0 && v2 > 0) ++ans;
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
