#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n, cnt = 0;
  long long x1, y1, x2, y2, x3, y3, c;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x3 >> y3 >> c;
    cnt += (x1 * x3 + y1 * y3 + c < 0 && x2 * x3 + y2 * y3 + c > 0) ||
           (x1 * x3 + y1 * y3 + c > 0 && x2 * x3 + y2 * y3 + c < 0);
  }
  cout << cnt;
  return 0;
}
