#include <bits/stdc++.h>
using namespace std;
bool intersect(int64_t a, int64_t b, int64_t c, int64_t x1, int64_t x2,
               int64_t y1, int64_t y2) {
  int64_t p1 = a * x1 + b * y1;
  int64_t p2 = a * x2 + b * y2;
  return (p1 > (-c)) ^ (p2 > (-c));
}
int main() {
  int64_t hx, hy;
  int64_t ux, uy;
  int64_t n;
  cin >> hx >> hy >> ux >> uy >> n;
  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    if (intersect(a, b, c, hx, ux, hy, uy)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
