#include <bits/stdc++.h>
using namespace std;
int n, ans;
int X1, Y1, X2, Y2;
void Work() {
  for (int i = 1; i <= n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (((a * X1 + b * Y1 + c) ^ (a * X2 + b * Y2 + c)) < 0) ans++;
  }
  printf("%d\n", ans);
}
void Init() {
  scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
  scanf("%d", &n);
}
int main() {
  Init();
  Work();
  return 0;
}
