#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, k = 0, n, a, b, t = 1, m, l = 0, y, c, ans, count1, countc,
                  x1, x2, y1, y2, first, second;
  while (t--) {
    cin >> x1 >> y1 >> x2 >> y2;
    cin >> n;
    ans = 0;
    first;
    second;
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      if (a * x1 + b * y1 + c < 0)
        first = 0;
      else
        first = 1;
      if (a * x2 + b * y2 + c < 0)
        second = 0;
      else
        second = 1;
      if (first != second) ans++;
    }
    cout << ans;
  }
  return 0;
}
