#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000,1000000000")
using namespace std;
struct point {
  long double x;
  long double y;
};
int main() {
  point p1, p2;
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  int n;
  int k = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long double a, b, c;
    cin >> a >> b >> c;
    long double t = (a * p1.x + b * p1.y + c) * (a * p2.x + b * p2.y + c);
    if (t < 0) k++;
  }
  cout << k;
}
