#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long x = a * x1 + b * y1 + c;
    long long y = a * x2 + b * y2 + c;
    if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
      continue;
    } else {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}
