#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int nax = 3e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll sx, sy;
  cin >> sx >> sy;
  ll ex, ey;
  cin >> ex >> ey;
  int n;
  cin >> n;
  int ans = 0;
  while (n--) {
    ll a, b, c;
    cin >> a >> b >> c;
    ll f = a * sx + b * sy + c;
    ll g = a * ex + b * ey + c;
    if (f > 0 && g < 0) ans++;
    if (f < 0 && g > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
