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