#include <bits/stdc++.h>
using namespace std;
int clockwise(double x1, double y1, double x2, double y2, double x3,
              double y3) {
  return ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) < 0;
}
bool intersect(double a, double b, double c, double x1, double y1, double x2,
               double y2) {
  double x3, x4, y3, y4;
  if (a != 0) {
    y3 = 1;
    y4 = 2;
    x3 = -(c + b * y3) / a;
    x4 = -(c + b * y4) / a;
  } else {
    y3 = -c / b;
    y4 = -c / b;
    x3 = 1;
    x4 = 2;
  }
  bool s1 = clockwise(x1, y1, x3, y3, x4, y4);
  bool s2 = clockwise(x2, y2, x3, y3, x4, y4);
  return s1 != s2;
}
int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    double a, b, c;
    cin >> a >> b >> c;
    ans += intersect(a, b, c, x1, y1, x2, y2);
  }
  cout << ans;
}
