#include <bits/stdc++.h>
using namespace std;
const int N = 300 + 10;
int a, b, c, n, sx, sy, tx, ty;
long long calc(int x, int y) { return 1ll * a * x + 1ll * b * y + 1ll * c; }
int main() {
  ios::sync_with_stdio(0);
  cin >> sx >> sy >> tx >> ty >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    long long k1 = calc(sx, sy), k2 = calc(tx, ty);
    if ((k1 > 0 && k2 < 0) || (k1 < 0 && k2 > 0)) ++ans;
  }
  cout << ans << endl;
  return 0;
}
