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