#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, y, n, m, i, j, a, b, c, r, a1, a2, ans = 0;
  cin >> x >> y >> n >> m >> r;
  for (i = 0; i < r; i++) {
    cin >> a >> b >> c;
    a1 = (x * a) + (y * b) + c;
    a2 = (n * a) + (m * b) + c;
    if (a1 < 0) {
      if (a2 > 0) ans++;
    }
    if (a1 > 0) {
      if (a2 < 0) ans++;
    }
  }
  cout << ans;
}
