#include <bits/stdc++.h>
using namespace std;
int main() {
  long long xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  long long n, a, b, c, ch = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if ((a * xa + b * ya + c > 0 && a * xb + b * yb + c < 0) ||
        (a * xa + b * ya + c < 0 && a * xb + b * yb + c > 0))
      ch++;
  }
  cout << ch;
}
