#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
const double EPS = 1e-9;
struct line {
  long long a, b, c;
};
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  long long x1, y1, x2, y2;
  int n;
  cin >> x1 >> y1 >> x2 >> y2 >> n;
  line lines[n];
  for (int i = 0; i < n; i++) {
    cin >> lines[i].a >> lines[i].b >> lines[i].c;
  }
  long long as = y2 - y1;
  long long bs = x1 - x2;
  long long cs = -as * x1 - bs * y1;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long ai = lines[i].a;
    long long bi = lines[i].b;
    long long ci = lines[i].c;
    long long delta = as * bi - ai * bs;
    if (delta == 0) {
      continue;
    }
    double x = (((bi * -1 * cs) - (-1 * ci * bs)) * 1.0) / delta;
    double y = (((as * ci * -1) - (ai * cs * -1)) * 1.0) / delta;
    if (x >= min(x1, x2) && x <= max(x1, x2) && y >= min(y1, y2) &&
        y <= max(y1, y2)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
