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