#include <bits/stdc++.h>
using namespace std;
int main() {
  int long long hx, hy, ux, uy, n, a, b, c, val1, val2, count = 0;
  cin >> hx >> hy;
  cin >> ux >> uy;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    val1 = a * hx + b * hy + c;
    val2 = a * ux + b * uy + c;
    if (val1 > 0 && val2 < 0)
      count++;
    else if (val1 < 0 && val2 > 0)
      count++;
  }
  cout << count << endl;
  return 0;
}
