#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VL = vector<long long>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MLL = map<LL, LL>;
int READ_INT() {
  int temp;
  cin >> temp;
  return temp;
}
LL READ_LONG() {
  LL temp;
  cin >> temp;
  return temp;
}
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0);
const double EPS = 1e-9;
int main() {
  ios::sync_with_stdio(false);
  LL x1, x2, y1, y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  int ans = 0, n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    LL a, b, c;
    cin >> a >> b >> c;
    LL p1 = a * x1 + b * y1 + c;
    LL p2 = a * x2 + b * y2 + c;
    if ((p1 > 0 && p2 < 0) || (p1 < 0 && p2 > 0)) ans++;
  }
  cout << ans << "\n";
  return 0;
}
