#include <bits/stdc++.h>
using namespace std;
int main() {
  double nowx;
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  long long a, b, c, u1, u2, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    u1 = a * x1 + b * y1 + c;
    u2 = a * x2 + b * y2 + c;
    if ((u1 > 0 && u2 < 0) || (u1 < 0 && u2 > 0)) ans++;
  }
  cout << ans << endl;
  return 0;
}
