#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x1, x2, y1, y2;
  scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
  long long int n;
  long long int i;
  scanf("%lld", &n);
  int a, b, c, count = 0;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    long long int tmp1 = a * x1 + b * y1 + c;
    long long int tmp2 = a * x2 + b * y2 + c;
    if (tmp1 < 0 && tmp2 > 0)
      count++;
    else if (tmp1 > 0 && tmp2 < 0)
      count++;
  }
  cout << count << endl;
  return 0;
}
