#include <bits/stdc++.h>
using namespace std;
void in() {}
int main() {
  in();
  long long x1, y1, x2, y2, cnt = 0;
  ;
  cin >> x1 >> y1 >> x2 >> y2;
  long long n, a, b, c, p1, p2;
  cin >> n;
  while (n--) {
    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)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
