#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  scanf("%d", &x);
  scanf("%d", &y);
  int x2, y2;
  scanf("%d", &x2);
  scanf("%d", &y2);
  int n, a, b, c;
  scanf("%d", &n);
  long long sign1, sign2;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    sign1 = (long long)a * x + (long long)b * y + (long long)c;
    sign2 = (long long)a * x2 + (long long)b * y2 + (long long)c;
    if ((sign1 < 0 && sign2 > 0) || (sign1 > 0 && sign2 < 0)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
