#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x;
  long long y;
  long long z;
};
point arr[305];
int main() {
  long long x1, y1, x2, y2, cnt, b1, c1, i, n, x, y, fx, mx, fy, my, val1, val2;
  cin >> x1 >> y1 >> x2 >> y2;
  cnt = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i].x >> arr[i].y >> arr[i].z;
    val1 = x1 * arr[i].x + y1 * arr[i].y + arr[i].z;
    val2 = x2 * arr[i].x + y2 * arr[i].y + arr[i].z;
    if ((val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0)) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
