#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int A[2][2], n, a, b, c, d, e, i, ans = 0;
  cin >> A[0][0] >> A[0][1] >> A[1][0] >> A[1][1];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c;
    d = (a * A[0][0] + b * A[0][1] + c);
    e = (a * A[1][0] + b * A[1][1] + c);
    if ((d > 0 && e < 0) || (d < 0 && e > 0)) ans++;
  }
  cout << ans << endl;
  return 0;
}
