#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
  int n = 0;
  cin >> x1 >> y1 >> x2 >> y2 >> n;
  int count = 0;
  for (int i = 0; i < n; ++i) {
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    int d1 = (a * 1LL * x1 + b * 1LL * y1 + c < 0 ? -1 : 1);
    int d2 = (a * 1LL * x2 + b * 1LL * y2 + c < 0 ? -1 : 1);
    if ((d1 * 1LL * d2) < 0) ++count;
  }
  cout << count;
  return 0;
}
