#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, y, xx, yy, dax[500], day[500], dac[500], i, j, k, l, n, q1,
      q2, a;
  while (cin >> x >> y >> xx >> yy >> n) {
    for (i = 0; i < n; i++) {
      cin >> dax[i] >> day[i] >> dac[i];
    }
    a = 0;
    for (i = 0; i < n; i++) {
      q1 = x * dax[i] + y * day[i] + dac[i];
      q2 = xx * dax[i] + yy * day[i] + dac[i];
      if (((q1 > 0) && (q2 < 0)) || ((q1 < 0) && (q2 > 0))) {
        a++;
      }
    }
    cout << a << endl;
  }
}
