#include <bits/stdc++.h>
using namespace std;
const int maxn = int(1e5) + 123;
const int inf = 1 << 30;
const int mod = int(1e9) + 7;
long long xa, ya, xb, yb, a, b, c, p, q;
int ans, n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> xa >> ya >> xb >> yb;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b >> c;
    p = a * xa + b * ya + c;
    q = a * xb + b * yb + c;
    if (p < 0 && q > 0 || p > 0 && q < 0) ans++;
  }
  cout << ans;
  return 0;
}
