#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1164777216")
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double pi = acos(-1.0), eps = 1e-15;
const int INF = 1000 * 1000 * 1000 + 5, MAXN = 100005, MOD = 1000007;
const long long INFL = 1000000000000000005;
void prepare(string s) {
  if ((int)s.size() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
long long x, y, X, Y, cnt = 0, n;
inline bool check(long long &a, long long &b, long long &c, long long x,
                  long long y) {
  return (a * x + b * y + c) < 0;
}
void solve() {
  cin >> x >> y >> X >> Y >> n;
  for (int i = 0; i < n; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (check(a, b, c, x, y) && !check(a, b, c, X, Y)) cnt++;
    if (!check(a, b, c, x, y) && check(a, b, c, X, Y)) cnt++;
  }
  cout << cnt;
}
int main() {
  prepare("");
  srand(time(NULL));
  solve();
  return 0;
}
