#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-5;
const int INF = 1000 * 1000 * 1000 + 1;
const long long LINF = (long long)1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long N = 1001;
void solve() {
  long long x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long z1 = a * x1 + b * y1 + c;
    long long z2 = a * x2 + b * y2 + c;
    if ((z1 > 0) && (z2 < 0)) ++res;
    if ((z1 < 0) && (z2 > 0)) ++res;
  }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
