#include <bits/stdc++.h>
using namespace std;
template <class Head, class... Tail>
inline void writeln(Head head, Tail... tail);
template <class Head, class... Tail>
inline void writeln2(Head head, Tail... tail);
template <class Head, class... Tail>
inline void readln(Head& head, Tail&... tail);
template <class Head, class... Tail>
inline void read(Head& head, Tail&... tail);
template <class Head, class... Tail>
inline void print(Head& head, Tail&... tail);
template <class Type1, class Type2>
inline void print(pair<Type1, Type2>& p);
template <class Type1, class Type2>
inline void print_no_space(pair<Type1, Type2>& p);
template <class Head, class... Tail>
inline void print_no_space(Head& head, Tail&... tail);
void inline writeln() { printf("\n"); }
void inline writeln2() { printf("\n"); }
void inline readln() {}
struct triple {
  long long a, b, c;
  triple(long long a, long long b, long long c) {
    this->a = a;
    this->b = b;
    this->c = c;
  }
};
int sign(long long a) { return a < 0 ? -1 : a > 0 ? 1 : 0; }
void run() {
  long long x1, x2, y1, y2, n, a, b, c, ans = 0;
  readln(x1, y1, x2, y2, n);
  for (int i = 0; i < (int)(n); ++i) {
    readln(a, b, c);
    if (sign(a * x1 + b * y1 + c) != sign(a * x2 + b * y2 + c)) ans++;
  }
  writeln(ans);
}
int main() {
  run();
  return 0;
}
inline void print(double a) {
  printf(
      " "
      "%f",
      a);
}
inline void print(int a) { printf(" %d", a); }
inline void print(const char* a) { printf(" %s", a); }
inline void print(string a) { printf(" %s", a.c_str()); }
inline void print(long long a) { printf(" %lld", a); }
inline void print(long a) { printf(" %ld", a); }
inline void print(unsigned long a) { printf(" %ld", a); }
inline void print(unsigned int a) { printf(" %d", a); }
inline void print(char a) { printf(" %c", a); }
inline void print_no_space(double a) { printf("%f", a); }
inline void print_no_space(int a) { printf("%d", a); }
inline void print_no_space(const char* a) { printf("%s", a); }
inline void print_no_space(string a) { printf("%s", a.c_str()); }
inline void print_no_space(long a) { printf("%ld", a); }
inline void print_no_space(long long a) { printf("%lld", a); }
inline void print_no_space(unsigned long a) { printf("%ld", a); }
inline void print_no_space(unsigned int a) { printf("%d", a); }
inline void print_no_space(char a) { printf("%c", a); }
template <class Type>
inline void print(vector<Type>& a) {
  for (int i = 0; i < a.size(); ++i) print(a[i]);
}
template <class Type>
inline void print(vector<vector<Type> >& a) {
  if (a.size()) (a.size() == 1) ? print(a[0]) : writeln2(a[0]);
  for (int i = 1; i < a.size() - 1; ++i) writeln2(a[i]);
  if (a.size() >= 2) print_no_space(a.back());
}
template <class Type>
inline void print_no_space(vector<Type>& a) {
  if (a.size()) print_no_space(a[0]);
  for (int i = 1; i < a.size(); ++i) print(a[i]);
}
template <class Type>
inline void print_no_space(vector<vector<Type> >& a) {
  for (int i = 0; i < a.size() - 1; ++i) writeln(a[i]);
  if (a.size()) print_no_space(a.back());
}
template <class Type1, class Type2>
inline void print_no_space(pair<Type1, Type2>& a) {
  print_no_space(a.first);
  writeln2(a.second);
}
template <class Type1, class Type2>
inline void print(pair<Type1, Type2>& a) {
  print_no_space(a.first);
  writeln2(a.second);
}
template <class Head, class... Tail>
inline void writeln2(Head head, Tail... tail) {
  print(head);
  writeln2(tail...);
}
template <class Head, class... Tail>
inline void writeln(Head head, Tail... tail) {
  print_no_space(head);
  writeln2(tail...);
}
inline void read(double& a) { scanf("%lf", &a); }
inline void read(int& a) { scanf("%d", &a); }
inline void read(string& a) { cin >> a; }
inline void read(long long& a) { scanf("%lld", &a); }
inline void read(char& a) { scanf("%c", &a); }
template <class Type1, class Type2>
inline void read(pair<Type1, Type2>& a) {
  readln(a.first, a.second);
}
template <class Type>
inline void read(vector<Type>& a) {
  if (a.size() == 0) {
    int n;
    read(n);
    a.resize(n);
  }
  for (int i = 0; i < a.size(); ++i) readln(a[i]);
}
template <class Head, class... Tail>
inline void readln(Head& head, Tail&... tail) {
  read(head);
  readln(tail...);
}
