#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e5 + 10;
int main() {
  long long x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long n, a, b, c, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if ((1ll * (a * x1 + b * y1 + c) < 0 && 1ll * (a * x2 + b * y2 + c) > 0) ||
        (1ll * (a * x1 + b * y1 + c) > 0 && 1ll * (a * x2 + b * y2 + c) < 0))
      ans++;
  }
  cout << ans;
  return 0;
}
