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