#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
template <typename T>
using vc = vector<T>;
template <typename T>
using uset = unordered_set<T>;
template <typename A, typename B>
using umap = unordered_map<A, B>;
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using minpq = priority_queue<T, vc<T>, greater<T>>;
template <typename T>
inline void sort(vc<T>& v) {
  sort(v.begin(), v.end());
}
template <typename T, typename Comp>
inline void sort(vc<T>& v, Comp c) {
  sort(v.begin(), v.end(), c);
}
using ll = long long;
using ull = unsigned long long;
using pii = pair<ll, ll>;
using vi = vc<ll>;
using vii = vc<pii>;
constexpr char el = '\n';
constexpr char sp = ' ';
constexpr ll INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3fLL;
ll xh, yh, xs, ys, n;
inline bool evan(ll a, ll b) { return a < 0 && b > 0 || a > 0 && b < 0; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cin >> xh >> yh;
  cin >> xs >> ys;
  cin >> n;
  ll ans = 0;
  while (n--) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (evan(a * xh + b * yh + c, a * xs + b * ys + c)) ans++;
  }
  cout << ans;
}
