#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long n;
  cin >> n;
  bool home[500];
  bool uni[500];
  long long A[500], B[500], C[500];
  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  for (int i = 0; i < n; i++) {
    if (A[i] == 0) {
      if (y1 < (double)(C[i]) / (double)B[i] * -1) {
        home[i] = false;
      } else {
        home[i] = true;
      }
      if (y2 < (double)C[i] / (double)B[i] * -1) {
        uni[i] = false;
      } else {
        uni[i] = true;
      }
    } else if (B[i] == 0) {
      if (x1 < (double)C[i] / (double)A[i] * -1) {
        home[i] = false;
      } else {
        home[i] = true;
      }
      if (x2 < (double)C[i] / (double)A[i] * -1) {
        uni[i] = false;
      } else {
        uni[i] = true;
      }
    } else {
      long long temp = A[i] * x1 + C[i];
      if (temp > y1 * B[i] * -1) {
        home[i] = false;
      } else {
        home[i] = true;
      }
      temp = A[i] * x2 + C[i];
      if (temp > y2 * B[i] * -1) {
        uni[i] = false;
      } else {
        uni[i] = true;
      }
    }
  }
  long long counter = 0;
  for (int i = 0; i < n; i++) {
    if (home[i] != uni[i]) {
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}
