#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int main() {
  int T, i, j, k, ca = 0, n, m;
  int x1, y1, x2, y2;
  while (~scanf("%d%d%d%d", &x1, &y1, &x2, &y2)) {
    scanf("%d", &n);
    int ans = 0, a, b, c;
    while (n--) {
      scanf("%d%d%d", &a, &b, &c);
      long long first = 1LL * a * x1 + 1LL * b * y1 + c,
                second = 1LL * a * x2 + 1LL * b * y2 + c;
      if (first > 0 && second < 0)
        ans++;
      else if (first < 0 && second > 0)
        ans++;
    }
    printf("%d\n", ans);
  }
}
