#include <bits/stdc++.h>
using namespace std;
int main() {
  long long xh, yh, xu, yu, at, bt, ct, ans = 0, n;
  cin >> xh >> yh >> xu >> yu >> n;
  while (n--) {
    cin >> at >> bt >> ct;
    ans += (at * xh + bt * yh < -ct) ^ (at * xu + bt * yu < -ct);
  }
  cout << ans;
}
