#include <bits/stdc++.h>
using namespace std;
double xs, ys, xf, yf;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin >> xs >> ys >> xf >> yf >> n;
  int t = 0;
  for (long long i = 0; i < (n); i++) {
    double a, b, c;
    cin >> a >> b >> c;
    if (a != 0 && b != 0) {
      bool f, s;
      if ((-c - xs * a) / b < ys)
        f = 1;
      else
        f = 0;
      if ((-c - xf * a) / b < yf)
        s = 1;
      else
        s = 0;
      if (f != s) t++;
    } else {
      double x, y;
      if (a == 0) {
        y = -c / b;
        bool f, s;
        if (y < ys) {
          f = 1;
        } else {
          f = 0;
        }
        if (y < yf) {
          s = 1;
        } else {
          s = 0;
        }
        if (f != s) t++;
      } else {
        x = -c / a;
        bool f, s;
        if (x < xs) {
          f = 1;
        } else {
          f = 0;
        }
        if (x < xf) {
          s = 1;
        } else {
          s = 0;
        }
        if (f != s) t++;
      }
    }
  }
  cout << t << endl;
}
