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