#include <bits/stdc++.h>
using namespace std;
const string INPUT_FILE = "input.txt";
const string OUTPUT_FILE = "output.txt";
inline bool IS_UPPERCH(char C) { return C >= 'A' && C <= 'Z'; }
inline bool IS_LOWERCH(char C) { return C >= 'a' && C <= 'z'; }
inline bool IS_LETTERCH(char C) { return IS_UPPERCH(C) || IS_LOWERCH(C); }
inline bool IS_DIGITCH(char C) { return C >= '0' && C <= '9'; }
inline char TO_LOWERCH(char C) { return (IS_UPPERCH(C)) ? (C + 32) : C; }
inline char TO_UPPERCH(char C) { return (IS_LOWERCH(C)) ? (C - 32) : C; }
int main() {
  float x1, x2, y1, y2;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  int N;
  cin >> N;
  int ans = 0;
  for (int i = (int)(0); i < (int)(N); ++i) {
    float a, b, c;
    cin >> a >> b >> c;
    if ((a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
