#include <bits/stdc++.h>
constexpr bool LOG = false;
using namespace std;
using vi = vector<int>;
using ll = long long;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;
void Log() {
  if (LOG) cerr << "\n";
}
template <class T, class... S>
void Log(T t, S... s) {
  if (LOG) cerr << t << "\t", Log(s...);
}
struct point {
  double x, y;
};
int ccw(point p, point q, point r) {
  double result = (r.x - q.x) * (p.y - q.y) - (r.y - q.y) * (p.x - q.x);
  if (result < 0) return -1;
  if (result > 0) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  point s, g;
  cin >> s.x >> s.y >> g.x >> g.y;
  int N;
  cin >> N;
  int ans = 0;
  for (auto i = decltype(N)(0); i < (N); i++) {
    double a, b, c;
    cin >> a >> b >> c;
    point p1, p2;
    if (a != 0) {
      p1 = {-c / a, 0};
      p2 = {-c / a + b, -a};
    } else {
      p1 = {0, -c / b};
      p2 = {b, -c / b - a};
    }
    auto result = ccw(p1, p2, s) * ccw(p1, p2, g);
    Log("result:", result);
    if (result < 0) ans++, Log(i);
  }
  cout << ans << "\n";
  return 0;
}
