#include <bits/stdc++.h>
using namespace std;
long long int sx, sy, dx, dy, ans, i, n, k, a, b, c, d, e;
int main() {
  cin >> sx >> sy;
  cin >> dx >> dy;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a >> b >> c;
    d = a * sx + b * sy + c;
    e = a * dx + b * dy + c;
    if (((d < 0) && (e > 0)) || ((e < 0) && (d > 0))) ans++;
  }
  cout << ans << endl;
}
