#include <bits/stdc++.h>
using namespace std;
int main() {
  long long p1, p2, x1, y1, x2, y2, a, b, c, n, cnt = 0;
  cin >> x1 >> y1 >> x2 >> y2 >> n;
  while (n--) {
    cin >> a >> b >> c;
    p1 = x1 * a + y1 * b + c;
    p2 = x2 * a + y2 * b + c;
    if (p1 > 0 && p2 < 0) cnt++;
    if (p1 < 0 && p2 > 0) cnt++;
  }
  cout << cnt;
  return 0;
}
