#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  int c = 0;
  for (int i = 0; i < n; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    long long p1 = x * x1 + y * y1 + z;
    long long p2 = x * x2 + y * y2 + z;
    if (p1 > 0 && p2 < 0)
      c++;
    else if (p1 < 0 && p2 > 0)
      c++;
  }
  cout << c << "\n";
  return 0;
}
