#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300 + 5;
long long p[2][2];
long long N;
int main() {
  cin >> p[0][0] >> p[0][1];
  cin >> p[1][0] >> p[1][1];
  cin >> N;
  long long a, b, c, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a >> b >> c;
    long long x = a * p[0][0] + b * p[0][1] + c;
    long long y = a * p[1][0] + b * p[1][1] + c;
    x /= abs(x);
    y /= abs(y);
    if (x * y < 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
