#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  long long x2, x3, y2, y3;
  cin >> x2 >> y2;
  cin >> x3 >> y3;
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long num1 = a * x2 + b * y2 + c;
    long long num2 = a * x3 + b * y3 + c;
    if ((num1 < 0 && num2 > 0) || (num1 > 0 && num2 < 0)) ans++;
  }
  cout << ans << endl;
  return 0;
}
