#include <bits/stdc++.h>
using namespace std;
struct PT {
  long long x, y;
};
PT p1, p2;
int n;
int main() {
  while (cin >> p1.x >> p1.y >> p2.x >> p2.y >> n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      long long a, b, c;
      cin >> a >> b >> c;
      int b1, b2;
      if (p1.x * a + p1.y * b + c > 0)
        b1 = 1;
      else
        b1 = 0;
      if (p2.x * a + p2.y * b + c > 0)
        b2 = 1;
      else
        b2 = 0;
      ans += (b1 ^ b2);
    }
    cout << ans << "\n";
  }
  return 0;
}
