#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, y1;
  scanf("%d%d", &x1, &y1);
  int x2, y2;
  scanf("%d%d", &x2, &y2);
  int n;
  scanf("%d", &n);
  int ans = 0;
  while (n--) {
    int a, b, c;
    scanf("%d%d", &a, &b);
    scanf("%d", &c);
    long long int v1 = x1 * 1LL * a + y1 * 1LL * b + c;
    long long int v2 = x2 * 1LL * a + y2 * 1LL * b + c;
    if ((v1 > 0 && v2 < 0) || (v1 < 0 && v2 > 0)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
