#include <bits/stdc++.h>
using namespace std;
inline int nxt() {
  int n;
  scanf("%d", &n);
  return n;
}
template <class T>
T sqr(T a) {
  return a * a;
}
inline bool check(long long a, long long b, long long c, pair<int, int> first,
                  pair<int, int> second) {
  if (a * first.first + b * first.second + c < 0 &&
      a * second.first + b * second.second + c > 0)
    return true;
  if (a * first.first + b * first.second + c > 0 &&
      a * second.first + b * second.second + c < 0)
    return true;
  return false;
}
inline void solve() {
  pair<int, int> first;
  pair<int, int> second;
  first.first = nxt();
  first.second = nxt();
  second.first = nxt();
  second.second = nxt();
  int n = nxt();
  long long a[n], b[n], c[n];
  for (int i = 0; i < n; ++i) {
    a[i] = nxt();
    b[i] = nxt();
    c[i] = nxt();
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (check(a[i], b[i], c[i], first, second)) {
      ++ans;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
