#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, y1, x2, y2, n, a, b, c, temp1, temp2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    temp1 = a * x1 + b * y1 + c;
    temp1 /= abs(temp1);
    temp2 = a * x2 + b * y2 + c;
    temp2 /= abs(temp2);
    if (temp1 * temp2 < 0) ans++;
  }
  cout << ans << endl;
}
