#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, x1, y1, x2, y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> n;
  int res = 0;
  for (int i = 0; i < n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long dir1 = a * x1 + b * y1 + c;
    long long dir2 = a * x2 + b * y2 + c;
    if ((dir1 > 0) != (dir2 > 0)) res++;
  }
  cout << res << endl;
  return 0;
}
