#include <bits/stdc++.h>
using namespace std;
struct line {
  long long int a, b, c;
};
int main() {
  long long int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long int n;
  cin >> n;
  vector<line> data(n);
  for (auto &p : data) {
    cin >> p.a >> p.b >> p.c;
  }
  vector<bool> s1(n), s2(n);
  for (int i = 0; i < n; ++i) {
    s1[i] = data[i].a * x1 + data[i].b * y1 + data[i].c > 0;
    s2[i] = data[i].a * x2 + data[i].b * y2 + data[i].c > 0;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += s1[i] ^ s2[i];
  }
  cout << cnt << endl;
  return 0;
}
