#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int maxn = 2020;
int n, x;
long long a, b, c;
void solve() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    x += (a * x1 + b * y1 + c > 0 && a * x2 + b * y2 + c < 0 ||
          a * x1 + b * y1 + c < 0 && a * x2 + b * y2 + c > 0);
  }
  cout << x;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
