#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int n, i, ans;
long long x1, y, x2, y2, t1, t2, a, b, c;
int main() {
  cin >> x1 >> y >> x2 >> y2 >> n;
  for (i = 1; i <= n; i++) {
    cin >> a >> b >> c;
    t1 = a * x1 + b * y + c;
    t2 = a * x2 + b * y2 + c;
    if ((t1 < 0 && t2 > 0) || (t1 > 0 && t2 < 0)) ans++;
  }
  cout << ans;
  return 0;
}
