#include <bits/stdc++.h>
struct point {
  long long int x;
  long long int y;
};
template <typename T>
int sgn(T val) {
  return (T(0) < val) - (val < T(0));
}
int main() {
  point A, B;
  long long int n, a, b, c;
  unsigned long int steps = 0;
  std::cin >> A.x;
  std::cin >> A.y;
  std::cin >> B.x;
  std::cin >> B.y;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    if (sgn(a * A.x + b * A.y + c) != sgn(a * B.x + b * B.y + c)) {
      ++steps;
    }
  }
  std::cout << steps;
  return 0;
}
