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