#include <bits/stdc++.h>
using namespace std;
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
long long toInt64(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double toDouble(string s) {
  double r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
string toString(long long n) {
  string s, s1;
  while (n / 10 > 0) {
    s += (char)((n % 10) + 48);
    n /= 10;
  }
  s += (char)((n % 10) + 48);
  n /= 10;
  s1 = s;
  for (int i = 0; i < s.length(); i++) s1[(s.length() - 1) - i] = s[i];
  return s1;
}
bool isUpperCase(char c) { return c >= 'A' && c <= 'Z'; }
bool isLowerCase(char c) { return c >= 'a' && c <= 'z'; }
bool isLetter(char c) { return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; }
bool isDigit(char c) { return c >= '0' && c <= '9'; }
char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }
char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  long long x1, y2, x2, y1;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> n;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long pos1 = (a * x1) + (b * y1) + c;
    long long pos2 = (a * x2) + (b * y2) + c;
    if (((pos1 > 0 && pos2 < 0) || (pos1 < 0 && pos2 > 0))) cnt++;
  }
  cout << cnt << endl;
}
