#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 100;
const int maxn = 2000000;
long long xx1, yy1, xx2, yy2, a, b, c, c1, c2;
int n, ans = 0;
int main() {
  cin >> xx1 >> yy1 >> xx2 >> yy2;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    c1 = a * xx1 + b * yy1 + c;
    c2 = a * xx2 + b * yy2 + c;
    if (c1 < 0 && c2 > 0)
      ans++;
    else if (c1 > 0 && c2 < 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
