#include <bits/stdc++.h>
using namespace std;
long double xx1, xx2, yy1, yy2;
int n;
int main() {
  cin >> xx1 >> yy1 >> xx2 >> yy2;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    long double a, b, c;
    cin >> a >> b >> c;
    long double Y1 = -(a * xx1 + c) / b;
    long double Y2 = -(a * xx2 + c) / b;
    if ((yy1 - Y1) * (yy2 - Y2) < 0) ans++;
  }
  cout << ans;
  return 0;
}
