#include <bits/stdc++.h>
using namespace std;
int main() {
  double x1, y1, x2, y2, a, b, c, m;
  while (cin >> x1 >> y1) {
    cin >> x2 >> y2;
    cin >> m;
    int ans = 0;
    for (int i = 0; i < m; i++) {
      cin >> a >> b >> c;
      double p1 = a * x1 + b * y1 + c;
      double p2 = a * x2 + b * y2 + c;
      if (p1 * p2 < 0) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
