#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, x2, y1, y2, a, b, c, n, ans = 0, t1, t2;
  cin >> x1 >> y1 >> x2 >> y2 >> n;
  while (n--) {
    cin >> a >> b >> c;
    t1 = a * x1 + b * y1 + c;
    if (t1 < 0)
      t1 = -1;
    else
      t1 = 1;
    t2 = a * x2 + b * y2 + c;
    if (t2 < 0)
      t2 = -1;
    else
      t2 = 1;
    if (t1 * t2 < 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
