#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
void solve() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  int ans = 0;
  long long a, b, c;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    long long v1 = a * x1 + b * y1 + c;
    long long v2 = a * x2 + b * y2 + c;
    if ((v1 < 0 and v2 > 0) or (v1 > 0 and v2 < 0)) ++ans;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  solve();
  return 0;
}
