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