#include <bits/stdc++.h>
using namespace std;
struct linea {
  double a, b, c;
  linea() : a(0), b(0), c(0) {}
  linea(double _a, double _b, double _c) : a(_a), b(_b), c(_c) {}
};
linea Orizz_alto, Orizz_basso, Vert_sx, Vert_dx;
linea tmp;
int N, divide;
pair<double, double> A, B, C, D;
bool Verticale() { return tmp.b == 0; }
bool Orizzontale() { return tmp.a == 0; }
bool Interseca() {
  double ris1 = tmp.a * A.first + tmp.b * A.second + tmp.c;
  double ris3 = tmp.a * B.first + tmp.b * B.second + tmp.c;
  if (ris1 * ris3 > 0)
    return false;
  else
    return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> A.first >> A.second >> B.first >> B.second;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> tmp.a >> tmp.b >> tmp.c;
    if (Interseca()) divide++;
  }
  cout << divide << endl;
  return 0;
}
