#include <bits/stdc++.h>
using namespace std;
struct line {
  long long int a, b, c;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long int n;
  cin >> n;
  line obj[n];
  for (long long int i = 0; i < n; i++) {
    cin >> obj[i].a >> obj[i].b >> obj[i].c;
  }
  long long int count = 0, val1, val2;
  for (long long int i = 0; i < n; i++) {
    val1 = (obj[i].a) * x1;
    val1 += (obj[i].b) * y1;
    val1 += obj[i].c;
    val2 = (obj[i].a) * x2;
    val2 += (obj[i].b) * y2;
    val2 += obj[i].c;
    if ((val1 < 0 && val2 > 0) || (val2 < 0 && val1 > 0)) {
      count++;
    }
  }
  cout << count;
  return 0;
}
