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