#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;
        x=a+b;
        y=c+d;
        ans=max(x,y);

        cout<<ans<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;
        x=0;
        if(c>b)
        {
            x=c-b;
        }
        ans=a+c-x;
        cout<<ans<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,a,b,c,d;
	for(scanf("%d",&t);t--;)
		scanf("%d%d%d%d",&a,&b,&c,&d),
		printf("%d\n",max(a+b,c+d));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,a,b,c,d;
	for(scanf("%d",&t);t--;)
		scanf("%d%d%d%d",&a,&b,&c,&d),
		printf("%d\n",max(a+b,c+d);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	return a+b;
}
int main()
{
	int t;
	cin>>t;
	while(t--) cout<<solve()<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	return max((a+b),(c+d));
}
int main()
{
	int t;
	cin>>t;
	while(t--) cout<<solve()<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	return ceil((a+b+c+d)/2.0);
}
int main()
{
	int t;
	cin>>t;
	while(t--) cout<<solve()<<endl;
	return 0;
}


/*
 * @Author: FuTianyu
 * @Date: 2020-11-01 22:59:30
 * @Last Modified by: FuTianyu
 * @Last Modified time: 2020-11-01 23:00:34
 */
#include<bits/stdc++.h>
using namespace std;

int a,b,c,d;

int main(){
    int T;
    scanf("%d",&T);
    while(T-->0){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        printf("%d\n",max(a+b,c+d));
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//map<long long,int>a;
int T,a,b,c,d;
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>a>>b>>c>>d;
		cout<<max(a+b,c+d)<<endl;
		//int A1=a,B1=c;
		//int A2=a,B2=b;
	}
}


#include<bits/stdc++.h>
using namespace std;
//map<long long,int>a;
int T,a,b,c,d;
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>a>>b>>c>>d;
		cout<<min(a+b,c+d)<<endl;
		//int A1=a,B1=c;
		//int A2=a,B2=b;
	}
}


#include<bits/stdc++.h>
using namespace std;
int T,a,b,c,d;

int main()
{
    cin>>T;
    while(T--)
    {
    	cin>>a>>b>>c>>d;
    	cout<<max(a,d)+min(b,c)<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int T,a,b,c,d;

int main()
{
    cin>>T;
    while(T--)
    {
    	cin>>a>>b>>c>>d;
    	cout<<max(a+b,c+d)<<endl;
	}
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int T, a, b, c, d;

int main() {
	scanf("%d", &T);
	while(T--) {
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf("%d\n", max(a + b, c + d));
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int t , a , b , c , d;

inline int read(){
	int s = 0 , w = 1;
	char ch = getchar();
	while((ch < '0') || (ch > '9')){
		if(ch == '-'){
			w = -1;
		}
		ch = getchar();
    }
   	while((ch >= '0') && (ch <= '9')){
   		s = (s << 3) + (s << 1) + ch - '0';
		ch = getchar();
	}
   	return s * w;
}

inline void write(int x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9){
    	write(x / 10);
	}
    putchar(x % 10 + '0');
    return ;
}

signed main(){

	t = read();

	while(t--){
		a = read();
		b = read();
		c = read();
		d = read();
		write(max(a + b , c + d));
		printf("\n");
	}

	return 0;
}


/* cinput
2
1 2 2 1
4 8 9 2
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 1e5 + 50, INF = 0x3f3f3f3f;

inline int read () {
	register int x = 0, w = 1;
	register char ch = getchar ();
	for (; ch < '0' || ch > '9'; ch = getchar ()) if (ch == '-') w = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar ()) x = x * 10 + ch - '0';
	return x * w;
}

inline void write (register int x) {
	if (x / 10) write (x / 10);
	putchar (x % 10 + '0');
}

int T;

int main () {
	T = read();
	while (T --) {
		register int a = read(), b = read(), c = read(), d = read();
		write (max (a + b, c + d)), putchar ('\n');
	}
	return 0;
}


    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    int t,a,b,c,d;
    int main()
    {
    	cin>>t;
    	while (t--)
    	{
    		cin>>a>>b>>c>>d;
    		cout<<max(a+b,c+d)<<endl;
    	}
    	return 0;
    }


#include<bits/stdc++.h>
using namespace std;
int t,a,b,c,d;
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		printf("%d\n",max(a+b,c+d));
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<max(a+b,c+d)<<endl;
	}
	return 0;
}


#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a+b,c+d)<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
	int T,a,b,c,d;
	cin>>T;
	while(T--){
		cin>>a>>b>>c>>d;
		int ans=max(a+b,c+d);
		cout<<ans<<endl;
	}
	return 0;
}
/*
*/


#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a+b,c+d);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<max(a+b,c+d)<<endl;
	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a+b,c+d);
    return 0;
}


#include <bits/stdc++.h>
//https://codeforces.com/problemset/problem/1445/B
#define ll long long
using namespace std;

int main()
{
    //freopen("n.inp","r",stdin);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        ll a,b,c,d,s=0;
        cin>>a>>b>>c>>d;
        s=min(a+b,c+d);
        cout<<s<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//https://codeforces.com/problemset/problem/1445/B
#define ll long long
using namespace std;

int main()
{
    freopen("n.inp","r",stdin);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        ll a,b,c,d,s=0;
        cin>>a>>b>>c>>d;
        s=a+b;
        cout<<s<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//https://codeforces.com/problemset/problem/1445/B
#define ll long long
using namespace std;

int main()
{
    //freopen("n.inp","r",stdin);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        ll a,b,c,d,s=0;
        cin>>a>>b>>c>>d;
        s=a+b;
        cout<<s<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//https://codeforces.com/problemset/problem/1445/B
#define ll long long
using namespace std;

int main()
{
    //freopen("n.inp","r",stdin);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        ll a,b,c,d,s=0;
        cin>>a>>b>>c>>d;
        s=max(a+b,c+d);
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
//https://codeforces.com/problemset/problem/1445/B
#define ll long long
using namespace std;

int main()
{
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        ll a,b,c,d,s=0;
        cin>>a>>b>>c>>d;
        s=min(a,c)+max(b,d);
        cout<<s<<endl;
    }
    return 0;
}


#include<iostream>

using namespace std;

int main()
{
    int t;
    cin>>t;
    for(int i =0;i<t;i++){
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        cout<< max(a+b, d+c);
    }
}


#include<iostream>

using namespace std;

int main()
{
    int t;
    cin>>t;
    for(int i =0;i<t;i++){
        long a, b, c, d;
        cin>>a>>b>>c>>d;
        cout<< min(a+b, d+c);
    }
}


#include<iostream>

using namespace std;

int main()
{
    int t;
    cin>>t;
    for(int i =0;i<t;i++){
        long a, b, c, d;
        cin>>a>>b>>c>>d;
        cout<< max(a+b, d+c)<<endl;
    }
}


#include<iostream>

using namespace std;

int main()
{
    int t;
    cin>>t;
    for(int i =0;i<t;i++){
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        cout<< min(a+b, d+c);
    }
}


#include<iostream>

using namespace std;

int main(){

	int n, temp[n];
	cin>>n;

	for(int i =0;i<n;i++){

		int a,b,c,d,temp1,temp2;
		cin>>a>>b>>c>>d;
		temp1=a+b;
		temp2=c+d;
		if(temp1>temp2)
			temp[i]=temp1;
		else
			temp[i]=temp2;
	}
	for(int i=0;i<n;i++){
		cout<<temp[i]<<endl;
	}
	return 0;

}


import java.util.*;
import java.io.*;

public class cf {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt(), y1 = sc.nextInt();
		int x2 = sc.nextInt(), y2 = sc.nextInt();
		int k = 0;
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
			if (a * x1 + b * y1 + c > 0 ^ a * x2 + b * y2 + c > 0) {
				k++;
			}
		}
		pw.println(k);
		pw.close();
	}

	static PrintWriter pw = new PrintWriter(System.out);

	public static class pair implements Comparable<pair> {
		long x;
		long y;

		public pair(long x, long y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public Integer[] nextsort(int n) throws IOException {
			Integer[] arr = new Integer[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


import java.util.*;
import java.io.*;

public class cf {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt(), y1 = sc.nextInt();
		int x2 = sc.nextInt(), y2 = sc.nextInt();
		int k = 0;
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
			Line l = new Line(new Point(0, (double) -c / b), new Point((double) -c / a, 0));
			if (b == 0) {
				l = new Line(new Point((double) -c / a, 1), new Point((double) -c / a, 0));
			} else if (a == 0) {
				l = new Line(new Point(0, (double) -c / b), new Point(1, (double) -c / b));
			}
			Point p1 = l.closestPoint(new Point(x1, y1));
			Point p2 = l.closestPoint(new Point(x2, y2));
//			pw.println(p1 + " " + p2);
//			pw.println(dist(p1.x, p1.y, x1, y1) + dist(p2.x, p2.y, x2, y2) + " " + dist(x1, y1, x2, y2));
			if (dist(p1.x, p1.y, x1, y1) + dist(p2.x, p2.y, x2, y2) <= dist(x1, y1, x2, y2)) {
				k++;
			}
		}
		pw.println(k);
		pw.close();
	}

	static double dist(double x1, double y1, double x2, double y2) {
		return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	}

	static double image(double x, Point p1, Point p2) {
		return (p1.y - p2.y) / (p1.x - p2.x) * (x - p1.x) + p1.y;
	}

	static PrintWriter pw = new PrintWriter(System.out);

	public static class Point implements Comparable<Point> {

		static final double EPS = 1e-4;

		double x, y;

		Point(double a, double b) {
			x = a;
			y = b;
		}

		public int compareTo(Point p) {
			if (Math.abs(x - p.x) > EPS)
				return x > p.x ? 1 : -1;
			if (Math.abs(y - p.y) > EPS)
				return y > p.y ? 1 : -1;
			return 0;
		}

		boolean between(Point p, Point q) {
			return x < Math.max(p.x, q.x) + EPS && x + EPS > Math.min(p.x, q.x) && y < Math.max(p.y, q.y) + EPS
					&& y + EPS > Math.min(p.y, q.y);
		}

		public String toString() {
			return x + " " + y;
		}

	}

	public static class Line {

		static final double INF = 1e9, EPS = 1e-9;

		double a, b, c;

		Line(Point p, Point q) {
			if (Math.abs(p.x - q.x) < EPS) {
				a = 1;
				b = 0;
				c = -p.x;
			} else {
				a = (p.y - q.y) / (q.x - p.x);
				b = 1.0;
				c = -(a * p.x + p.y);
			}

		}

		Line(Point p, double m) {
			a = -m;
			b = 1;
			c = -(a * p.x + p.y);
		}

		boolean parallel(Line l) {
			return Math.abs(a - l.a) < EPS && Math.abs(b - l.b) < EPS;
		}

		boolean same(Line l) {
			return parallel(l) && Math.abs(c - l.c) < EPS;
		}

		Point intersect(Line l) {
			if (parallel(l))
				return null;
			double x = (b * l.c - c * l.b) / (a * l.b - b * l.a);
			double y;
			if (Math.abs(b) < EPS)
				y = -l.a * x - l.c;
			else
				y = -a * x - c;

			return new Point(x, y);
		}

		Point closestPoint(Point p) {
			if (Math.abs(b) < EPS)
				return new Point(-c, p.y);
			if (Math.abs(a) < EPS)
				return new Point(p.x, -c);
			return intersect(new Line(p, 1 / a));
		}

	}

	public static class pair implements Comparable<pair> {
		long x;
		long y;

		public pair(long x, long y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public Integer[] nextsort(int n) throws IOException {
			Integer[] arr = new Integer[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


import java.util.*;
import java.io.*;

public class cf {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt(), y1 = sc.nextInt();
		int x2 = sc.nextInt(), y2 = sc.nextInt();
		int c = 0;
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			Line l = new Line(sc.nextInt(), sc.nextInt(), sc.nextInt());
			Point p1 = l.closestPoint(new Point(x1, y1));
			Point p2 = l.closestPoint(new Point(x2, y2));
//			pw.println(p1 + " " + p2);
			if (dist(p1.x, p1.y, x1, y1) + dist(p2.x, p2.y, x2, y2) <= dist(x1, y1, x2, y2)) {
				c++;
			}
		}
		pw.println(c);
		pw.close();
	}

	static double dist(double x1, double y1, double x2, double y2) {
		return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	}

	static PrintWriter pw = new PrintWriter(System.out);

	public static class Point implements Comparable<Point> {

		static final double EPS = 1e-4;

		double x, y;

		Point(double a, double b) {
			x = a;
			y = b;
		}

		public int compareTo(Point p) {
			if (Math.abs(x - p.x) > EPS)
				return x > p.x ? 1 : -1;
			if (Math.abs(y - p.y) > EPS)
				return y > p.y ? 1 : -1;
			return 0;
		}

		boolean between(Point p, Point q) {
			return x < Math.max(p.x, q.x) + EPS && x + EPS > Math.min(p.x, q.x) && y < Math.max(p.y, q.y) + EPS
					&& y + EPS > Math.min(p.y, q.y);
		}

		public String toString() {
			return x + " " + y;
		}

	}

	public static class Line {

		static final double INF = 1e9, EPS = 1e-9;

		double a, b, c;

		Line(Point p, Point q) {
			if (Math.abs(p.x - q.x) < EPS) {
				a = 1;
				b = 0;
				c = -p.x;
			} else {
				a = (p.y - q.y) / (q.x - p.x);
				b = 1.0;
				c = -(a * p.x + p.y);
			}

		}

		Line(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		Line(Point p, double m) {
			a = -m;
			b = 1;
			c = -(a * p.x + p.y);
		}

		boolean parallel(Line l) {
			return Math.abs(a - l.a) < EPS && Math.abs(b - l.b) < EPS;
		}

		boolean same(Line l) {
			return parallel(l) && Math.abs(c - l.c) < EPS;
		}

		Point intersect(Line l) {
			if (parallel(l))
				return null;
			double x = (b * l.c - c * l.b) / (a * l.b - b * l.a);
			double y;
			if (Math.abs(b) < EPS)
				y = -l.a * x - l.c;
			else
				y = -a * x - c;

			return new Point(x, y);
		}

		Point closestPoint(Point p) {
			if (Math.abs(b) < EPS)
				return new Point(-c, p.y);
			if (Math.abs(a) < EPS)
				return new Point(p.x, -c);
			return intersect(new Line(p, 1 / a));
		}

	}

	public static class pair implements Comparable<pair> {
		long x;
		long y;

		public pair(long x, long y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public Integer[] nextsort(int n) throws IOException {
			Integer[] arr = new Integer[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTown {
	static final double EPS = 1e-9;
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		Point home = new Point(sc.nextDouble(),sc.nextDouble());
		Point uni = new Point(sc.nextDouble(),sc.nextDouble());
		int n = sc.nextInt();
		int lines = 0;
		for(int i = 0;i<n;i++)
		{
			Line l = new Line(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
			if((calc(home,l) + EPS < 0) != (calc(uni,l) + EPS < 0))
				lines++;
		}
		System.out.println(lines);
	}
	static double calc(Point p,Line l)
	{
		return (p.x * l.a) + (p.y * l.b) + (l.c);
	}
	static class Point
	{
		double x,y;
		Point(double a,double b)
		{
			x = a;
			y = b;
		}
	}
	static class Line
	{
		double a,b,c;
		Line(double a,double b,double c)
		{
			this.a = a;
			this.b = b;
			this.c = c;
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		public long[] nextLongArr(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextLong();
			return arr;
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);

		String r[]=br.readLine().split(" ");
		int xh=Integer.parseInt(r[0]);
		int yh=Integer.parseInt(r[1]);

		 r=br.readLine().split(" ");

		int xu=Integer.parseInt(r[0]);
		int yu=Integer.parseInt(r[1]);

		int lines=0;
		int n=Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			r=br.readLine().split(" ");
			long a=Integer.parseInt(r[0]);
			long b=Integer.parseInt(r[1]);
			long c=Integer.parseInt(r[2]);

				//good note if 2 points are on opposite sides of the line there subist coord in line equ will have diff signs
				long s1=a*xu+b*yu+c;
				long s2=a*xh+b*yh+c;
				if((s2>0&&s1<0)||(s2<0&&s1>0))
					lines++;

		}

		out.println(lines);
		out.flush();

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main4 {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);

		String r[]=br.readLine().split(" ");
		int xh=Integer.parseInt(r[0]);
		int yh=Integer.parseInt(r[1]);
		Point home=new Point(xh,yh);
		 r=br.readLine().split(" ");

		int xu=Integer.parseInt(r[0]);
		int yu=Integer.parseInt(r[1]);
		Point uni=new Point(xu,yu);
		int lines=0;
		int n=Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			r=br.readLine().split(" ");
			int a=Integer.parseInt(r[0]);
			int b=Integer.parseInt(r[1]);
			int c=Integer.parseInt(r[2]);
			Point p1,p2;
			if(a!=0)
				p1=new Point((double)(-c-c*b)/(double)a,c);
			else
				p1=new Point(200000,(double)-c/(double)b);
				if(b!=0)
					p2=new Point(c,(double)(-c-c*a)/(double)b);
				else
					p2=new Point((double)-c/(double)a,2000000);

				boolean m1=Point.ccw(p1, home, p2);
				boolean m2=Point.ccw(p1, uni, p2);
				//System.out.println(p1.x+"  "+p1.y+"    "+p2.x+"  "+p2.y);
				if(m1!=m2)
					lines++;

		}

		out.println(lines);
		out.flush();

	}
	static  class Line {

		static final double INF = 1e9, EPS = 1e-9;

		double a, b, c;

		Line(Point p, Point q)
		{
			if(Math.abs(p.x - q.x) < EPS) {	a = 1; b = 0; c = -p.x;	}
			else
			{
				a = (p.y - q.y) / (q.x - p.x);
				b = 1.0;
				c = -(a * p.x + p.y);
			}

		}

		Line(Point p, double m) { a = -m; b = 1; c =  -(a * p.x + p.y); }
		Line(double m,double yinterc ) { a = -m; b = 1; c = -yinterc; }
		boolean parallel(Line l) { return Math.abs(a - l.a) < EPS && Math.abs(b - l.b) < EPS; }

		boolean same(Line l) { return parallel(l) && Math.abs(c - l.c) < EPS; }

		Point intersect(Line l)
		{
			if(parallel(l))
				return null;
			double x = (b * l.c - c * l.b) / (a * l.b - b * l.a);
			double y;
			if(Math.abs(b) < EPS)
				 y = -l.a * x - l.c;
			else
				y = -a * x - c;

			return new Point(x, y);
		}

		Point closestPoint(Point p)
		{
			if(Math.abs(b) < EPS) return new Point(-c, p.y);
			if(Math.abs(a) < EPS) return new Point(p.x, -c);
			return intersect(new Line(p, 1 / a));
		}

	}
	static  class Point implements Comparable<Point>{

		static final double EPS = 1e-9;

		double x, y;

		Point(double a, double b) { x = a; y = b; }

		public int compareTo(Point p)
		{
			if(Math.abs(x - p.x) > EPS) return x > p.x ? 1 : -1;
			if(Math.abs(y - p.y) > EPS) return y > p.y ? 1 : -1;
			return 0;
		}

		public double dist(Point p) { return Math.sqrt(sq(x - p.x) + sq(y - p.y)); }

		static double sq(double x) { return x * x; }

		Point rotate(double angle)
		{
			double c = Math.cos(angle), s = Math.sin(angle);
			return new Point(x * c - y * s, x * s + y * c);
		}
		// for integer points and rotation by 90 (counterclockwise) : swap x and y, negate x

		Point rotate(double theta, Point p)			//rotate around p
		{
			Vector v = new Vector(p, new Point(0, 0));
			return translate(v).rotate(theta).translate(v.reverse());
		}

		Point translate(Vector v) { return new Point(x + v.x , y + v.y); }

		Point reflectionPoint(Line l) 	//reflection point of p on line l
		{
			Point p = l.closestPoint(this);
			Vector v = new Vector(this, p);
			return this.translate(v).translate(v);
		}

		boolean between(Point p, Point q)
		{
			return x < Math.max(p.x, q.x) + EPS && x + EPS > Math.min(p.x, q.x)
					&& y < Math.max(p.y, q.y) + EPS && y + EPS > Math.min(p.y, q.y);
		}

		//returns true if it is on the line defined by a and b
		boolean onLine(Point a, Point b)
		{
			if(a.compareTo(b) == 0) return compareTo(a) == 0;
			return Math.abs(new Vector(a, b).cross(new Vector(a, this))) < EPS;
		}

		boolean onSegment(Point a, Point b)
		{
			if(a.compareTo(b) == 0) return compareTo(a) == 0;
			return onRay(a, b) && onRay(b, a);
		}

		//returns true if it is on the ray whose start point is a and passes through b
		boolean onRay(Point a, Point b)
		{
			if(a.compareTo(b) == 0) return compareTo(a) == 0;
			return new Vector(a, b).normalize().equals(new Vector(a, this).normalize());	//implement equals()
		}

		// returns true if it is on the left side of Line pq
		// add EPS to LHS if on-line points are accepted
		static boolean ccw(Point p, Point q, Point r)
		{
			return new Vector(p, q).cross(new Vector(p, r)) > 0;
		}

		static boolean collinear(Point p, Point q, Point r)
		{
			return Math.abs(new Vector(p, q).cross(new Vector(p, r))) < EPS;
		}

		static double angle(Point a, Point o, Point b)  // angle AOB
		{
			Vector oa = new Vector(o, a), ob = new Vector(o, b);
			return Math.acos(oa.dot(ob) / Math.sqrt(oa.norm2() * ob.norm2()));
		}

		static double distToLine(Point p, Point a, Point b) //distance between point p and a line defined by points a, b (a != b)
		{
			if(a.compareTo(b) == 0) p.dist(a);
			// formula: c = a + u * ab
			Vector ap = new Vector(a, p), ab = new Vector(a, b);
			double u = ap.dot(ab) / ab.norm2();
			Point c = a.translate(ab.scale(u));
			return p.dist(c);
		}
		// Another way: find closest point and calculate the distance between it and p

		static double distToLineSegment(Point p, Point a, Point b)
		{
			Vector ap = new Vector(a, p), ab = new Vector(a, b);
			double u = ap.dot(ab) / ab.norm2();
			if (u < 0.0) return p.dist(a);
			if (u > 1.0) return p.dist(b);
			return distToLine(p, a, b);
		}
		// Another way: find closest point and calculate the distance between it and p
	}

	static class Vector {

		double x, y;

		Vector(double a, double b) { x = a; y = b; }

		Vector(Point a, Point b) { this(b.x - a.x, b.y - a.y); }

		Vector scale(double s) { return new Vector(x * s, y * s); }              //s is a non-negative value

		double dot(Vector v) { return (x * v.x + y * v.y); }

		double cross(Vector v) { return x * v.y - y * v.x; }

		double norm2() { return x * x + y * y; }

		Vector reverse() { return new Vector(-x, -y); }

		Vector normalize()
		{
			double d = Math.sqrt(norm2());
			return scale(1 / d);
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main4 {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);

		String r[]=br.readLine().split(" ");
		int xh=Integer.parseInt(r[0]);
		int yh=Integer.parseInt(r[1]);
		Point home=new Point(xh,yh);
		 r=br.readLine().split(" ");

		long xu=Integer.parseInt(r[0]);
		long yu=Integer.parseInt(r[1]);
		Point uni=new Point(xu,yu);
		int lines=0;
		int n=Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			r=br.readLine().split(" ");
			long a=Integer.parseInt(r[0]);
			long b=Integer.parseInt(r[1]);
			long c=Integer.parseInt(r[2]);
			Point p1,p2;
			if(a!=0)
				p1=new Point((double)(-c-c*b)/(double)a,c);
			else
				p1=new Point(200000,(double)-c/(double)b);
				if(b!=0)
					p2=new Point(c,(double)(-c-c*a)/(double)b);
				else
					p2=new Point((double)-c/(double)a,2000000);

				boolean m1=Point.ccw(p1, home, p2);
				boolean m2=Point.ccw(p1, uni, p2);
				//System.out.println(p1.x+"  "+p1.y+"    "+p2.x+"  "+p2.y);
				if(m1!=m2)
					lines++;

		}

		out.println(lines);
		out.flush();

	}
	static  class Line {

		static final double INF = 1e9, EPS = 1e-9;

		double a, b, c;

		Line(Point p, Point q)
		{
			if(Math.abs(p.x - q.x) < EPS) {	a = 1; b = 0; c = -p.x;	}
			else
			{
				a = (p.y - q.y) / (q.x - p.x);
				b = 1.0;
				c = -(a * p.x + p.y);
			}

		}

		Line(Point p, double m) { a = -m; b = 1; c =  -(a * p.x + p.y); }
		Line(double m,double yinterc ) { a = -m; b = 1; c = -yinterc; }
		boolean parallel(Line l) { return Math.abs(a - l.a) < EPS && Math.abs(b - l.b) < EPS; }

		boolean same(Line l) { return parallel(l) && Math.abs(c - l.c) < EPS; }

		Point intersect(Line l)
		{
			if(parallel(l))
				return null;
			double x = (b * l.c - c * l.b) / (a * l.b - b * l.a);
			double y;
			if(Math.abs(b) < EPS)
				 y = -l.a * x - l.c;
			else
				y = -a * x - c;

			return new Point(x, y);
		}

		Point closestPoint(Point p)
		{
			if(Math.abs(b) < EPS) return new Point(-c, p.y);
			if(Math.abs(a) < EPS) return new Point(p.x, -c);
			return intersect(new Line(p, 1 / a));
		}

	}
	static  class Point implements Comparable<Point>{

		static final double EPS = 1e-9;

		double x, y;

		Point(double a, double b) { x = a; y = b; }

		public int compareTo(Point p)
		{
			if(Math.abs(x - p.x) > EPS) return x > p.x ? 1 : -1;
			if(Math.abs(y - p.y) > EPS) return y > p.y ? 1 : -1;
			return 0;
		}

		public double dist(Point p) { return Math.sqrt(sq(x - p.x) + sq(y - p.y)); }

		static double sq(double x) { return x * x; }

		Point rotate(double angle)
		{
			double c = Math.cos(angle), s = Math.sin(angle);
			return new Point(x * c - y * s, x * s + y * c);
		}
		// for integer points and rotation by 90 (counterclockwise) : swap x and y, negate x

		Point rotate(double theta, Point p)			//rotate around p
		{
			Vector v = new Vector(p, new Point(0, 0));
			return translate(v).rotate(theta).translate(v.reverse());
		}

		Point translate(Vector v) { return new Point(x + v.x , y + v.y); }

		Point reflectionPoint(Line l) 	//reflection point of p on line l
		{
			Point p = l.closestPoint(this);
			Vector v = new Vector(this, p);
			return this.translate(v).translate(v);
		}

		boolean between(Point p, Point q)
		{
			return x < Math.max(p.x, q.x) + EPS && x + EPS > Math.min(p.x, q.x)
					&& y < Math.max(p.y, q.y) + EPS && y + EPS > Math.min(p.y, q.y);
		}

		//returns true if it is on the line defined by a and b
		boolean onLine(Point a, Point b)
		{
			if(a.compareTo(b) == 0) return compareTo(a) == 0;
			return Math.abs(new Vector(a, b).cross(new Vector(a, this))) < EPS;
		}

		boolean onSegment(Point a, Point b)
		{
			if(a.compareTo(b) == 0) return compareTo(a) == 0;
			return onRay(a, b) && onRay(b, a);
		}

		//returns true if it is on the ray whose start point is a and passes through b
		boolean onRay(Point a, Point b)
		{
			if(a.compareTo(b) == 0) return compareTo(a) == 0;
			return new Vector(a, b).normalize().equals(new Vector(a, this).normalize());	//implement equals()
		}

		// returns true if it is on the left side of Line pq
		// add EPS to LHS if on-line points are accepted
		static boolean ccw(Point p, Point q, Point r)
		{
			return new Vector(p, q).cross(new Vector(p, r)) > 0;
		}

		static boolean collinear(Point p, Point q, Point r)
		{
			return Math.abs(new Vector(p, q).cross(new Vector(p, r))) < EPS;
		}

		static double angle(Point a, Point o, Point b)  // angle AOB
		{
			Vector oa = new Vector(o, a), ob = new Vector(o, b);
			return Math.acos(oa.dot(ob) / Math.sqrt(oa.norm2() * ob.norm2()));
		}

		static double distToLine(Point p, Point a, Point b) //distance between point p and a line defined by points a, b (a != b)
		{
			if(a.compareTo(b) == 0) p.dist(a);
			// formula: c = a + u * ab
			Vector ap = new Vector(a, p), ab = new Vector(a, b);
			double u = ap.dot(ab) / ab.norm2();
			Point c = a.translate(ab.scale(u));
			return p.dist(c);
		}
		// Another way: find closest point and calculate the distance between it and p

		static double distToLineSegment(Point p, Point a, Point b)
		{
			Vector ap = new Vector(a, p), ab = new Vector(a, b);
			double u = ap.dot(ab) / ab.norm2();
			if (u < 0.0) return p.dist(a);
			if (u > 1.0) return p.dist(b);
			return distToLine(p, a, b);
		}
		// Another way: find closest point and calculate the distance between it and p
	}

	static class Vector {

		double x, y;

		Vector(double a, double b) { x = a; y = b; }

		Vector(Point a, Point b) { this(b.x - a.x, b.y - a.y); }

		Vector scale(double s) { return new Vector(x * s, y * s); }              //s is a non-negative value

		double dot(Vector v) { return (x * v.x + y * v.y); }

		double cross(Vector v) { return x * v.y - y * v.x; }

		double norm2() { return x * x + y * y; }

		Vector reverse() { return new Vector(-x, -y); }

		Vector normalize()
		{
			double d = Math.sqrt(norm2());
			return scale(1 / d);
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);

		String r[]=br.readLine().split(" ");
		int xh=Integer.parseInt(r[0]);
		int yh=Integer.parseInt(r[1]);

		 r=br.readLine().split(" ");

		int xu=Integer.parseInt(r[0]);
		int yu=Integer.parseInt(r[1]);

		int lines=0;
		int n=Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			r=br.readLine().split(" ");
			int a=Integer.parseInt(r[0]);
			int b=Integer.parseInt(r[1]);
			int c=Integer.parseInt(r[2]);

				//good note if 2 points are on opposite sides of the line there subist coord in line equ will have diff signs
				int s1=a*xu+b*yu+c;
				int s2=a*xh+b*yh+c;
				if((s2>0&&s1<0)||(s2<0&&s1>0))
					lines++;

		}

		out.println(lines);
		out.flush();

	}
}


import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x1 = sc.nextInt();
        long y1 = sc.nextInt();
        long x2 = sc.nextInt();
        long y2 = sc.nextInt();
        long n = sc.nextInt();
        int res = 0;
        // System.out.println(n);
        for(int i = 0;i<n;i++){
            long a = sc.nextInt();
            long b = sc.nextInt();
            long c = sc.nextInt();

            if((a*x1 + b *y1 + c >0 && a*x2 + b*y2+c <0)|| (a*x1 + b *y1 + c <0 && a*x2 + b*y2+c >0)){

                res++;
            }
        }
        System.out.println(res);
    }
}


import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int n = sc.nextInt();
        int res = 0;
        // System.out.println(n);
        for(int i = 0;i<n;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();

            if((a*x1 + b *y1 + c >0 && a*x2 + b*y2+c <0)|| (a*x1 + b *y1 + c <0 && a*x2 + b*y2+c >0)){

                res++;
            }
        }
        System.out.println(res);
    }
}


import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int n = sc.nextInt();
        int res = 0;
        for(int i = 0;i<n;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if((a*x1 + b *y1 + c >0 && a*x2 + b*y2*c <0)|| (a*x1 + b *y1 + c <0 && a*x2 + b*y2*c >0)){
                res++;
            }
        }
        System.out.println(res);
    }
}


import java.util.Scanner;
public class C {
    public static void main(String[]args){
        Scanner in=new Scanner(System.in);
        int sum=0;
        double x=1.0,y=1.0,z=1.0;
        int hx=in.nextInt();
        int hy=in.nextInt();
        int sx=in.nextInt();
        int sy=in.nextInt();
        int n=in.nextInt();
        if(sx==hx) {
            for(int i=0;i<n;i++){
                double xx=in.nextDouble();
                double yx=in.nextDouble();
                double zx=in.nextDouble();
                if(yx!=0&&((zx<=hy&&zx>=sy)||(zx>=hy&&zx<=sy))){
                    sum++;
                }
                else continue;
            }
        }
        else {
            if(sy==hy) {
            x=0;
            z=sy;
        }
        else{
        x=-1.0/(sx-hx);
        y=-1.0/(sy-hy);
        z=hy/(sy-hy)-hx/(sx-hx);
        }
//      point[] points=new point[300];
//      for(int i=0;i<points.length;i++){
//          points[i]=new point();
//      }

        for(int i=0;i<n;i++){
            double xq=0;
            double xin=in.nextDouble();
            double yin=in.nextDouble();
            double zin=in.nextDouble();
            if(yin==0){
                if((hx>=zin&&sx<=zin)||(hx<=zin&&sx>=zin)){
                    sum++;
                }
            }
            else if(xin/yin==x/y) continue;
            else{
            xq=po(x,y,z,xin,yin,zin);
            if((hx>=xq&&sx<=xq)||(hx<=xq&&sx>=xq)){
                sum++;
            }
        }
        }
        }
        System.out.println(sum);

    }
    public static double po(double x1, double y1,double z1, double x2, double y2, double z2){
        double ans;
        ans=(z1*y2-z2*y1)/(x1*y2-x2*y1);
        //ans[1]=(x1*z2-x2*z1)/(x1*y2-x2*y1);
        return ans;
    }
}
class point{
    public double x;
    public double y;
    public int num;
    point(double x, double y){
        this.x=x;
        this.y=y;
        this.num=1;
    }
    point(){
        this.x=Double.NEGATIVE_INFINITY;
        this.y=Double.NEGATIVE_INFINITY;
        this.num=-1;
    }
}


import java.util.Scanner;
public class C285C2 {
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		double x1=in.nextDouble();
		double y1=in.nextDouble();
		double x2=in.nextDouble();
		double y2=in.nextDouble();
		int n=in.nextInt();
		int sum=0;
		for(int i=0;i<n;i++){
			double a=in.nextDouble();
			double b=in.nextDouble();
			double c=in.nextDouble();
			if((a*x1+b*y1+c)*(a*x2+b*y2+c)<0)
				sum++;
		}
		System.out.print(sum);
	}
}


import java.util.Scanner;
public class C {
    public static void main(String[]args){
        Scanner in=new Scanner(System.in);
        int sum=0;
        double x=1.0,y=1.0,z=1.0;
        double hx=in.nextDouble();
        double hy=in.nextDouble();
        double sx=in.nextDouble();
        double sy=in.nextDouble();
        int n=in.nextInt();
        if(sx==hx) {
            for(int i=0;i<n;i++){
                double xx=in.nextDouble();
                double yx=in.nextDouble();
                double zx=in.nextDouble();
                if(yx!=0&&((zx<=hy&&zx>=sy)||(zx>=hy&&zx<=sy))){
                    sum++;
                }
                else continue;
            }
        }
        else {
            if(sy==hy) {
            x=0;
            z=sy;
        }
        else{
        x=-1.0/(sx-hx);
        y=-1.0/(sy-hy);
        z=hy/(sy-hy)-hx/(sx-hx);
        }
//      point[] points=new point[300];
//      for(int i=0;i<points.length;i++){
//          points[i]=new point();
//      }

        for(int i=0;i<n;i++){
            double xq=0;
            double xin=in.nextDouble();
            double yin=in.nextDouble();
            double zin=in.nextDouble();
            if(yin==0){
                if((hx>=zin&&sx<=zin)||(hx<=zin&&sx>=zin)){
                    sum++;
                }
            }
            else if(xin/yin==x/y) continue;
            else{
            xq=po(x,y,z,xin,yin,zin);
            if((hx>=xq&&sx<=xq)||(hx<=xq&&sx>=xq)){
                sum++;
            }
        }
        }
        }
        System.out.println(sum);

    }
    public static double po(double x1, double y1,double z1, double x2, double y2, double z2){
        double ans;
        ans=(z1*y2-z2*y1)/(x1*y2-x2*y1);
        //ans[1]=(x1*z2-x2*z1)/(x1*y2-x2*y1);
        return ans;
    }
}
class point{
    public double x;
    public double y;
    public int num;
    point(double x, double y){
        this.x=x;
        this.y=y;
        this.num=1;
    }
    point(){
        this.x=Double.NEGATIVE_INFINITY;
        this.y=Double.NEGATIVE_INFINITY;
        this.num=-1;
    }
}


import java.util.*;
public class crazyTown{

	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int n = sc.nextInt();
		int a = 0;
		int b = 0;
		int c = 0;
		double a1,a2;
		int ans = 0;
		for (int i = 0;i<n ;i++ ) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();

			a1 = (double)((double)a*(double)x1)+((double)b*(double)y1)+(double)c;
			a2 = (double)((double)a*(double)x2)+((double)b*(double)y2)+(double)c;
			//System.out.println("a1 "+a1+"   a2 "+a2+"  sum"+((double)a1*a2));
			if ((double)a1*(double)a2 < 0) {
				//System.out.println("try "+i+"ans "+((a * x1 + b * y1 + c) * (a * x2 + b * y2 + c)));
				ans+=1;
			}

		}
		System.out.println(""+ans);
	}
}


import java.util.*;
public class crazyTown{

	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int n = sc.nextInt();
		int a = 0;
		int b = 0;
		int c = 0;
		double a1,a2;
		int ans = 0;
		for (int i = 0;i<n ;i++ ) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();

			a1 = (double)((double)a*(double)x1)+((double)b*(double)y1)+(double)c;
			a2 = (double)((double)a*(double)x2)+((double)b*(double)y2)+(double)c;
			System.out.println("a1 "+a1+"   a2 "+a2+"  sum"+((double)a1*a2));
			if ((double)a1*(double)a2 < 0) {
				System.out.println("try "+i+"ans "+((a * x1 + b * y1 + c) * (a * x2 + b * y2 + c)));
				ans+=1;
			}

		}
		System.out.println(""+ans);
	}
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF498A extends PrintWriter {
	CF498A() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF498A o = new CF498A(); o.main(); o.flush();
	}

	void main() {
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int n = sc.nextInt();
		int cnt = 0;
		while (n-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if (Long.signum((long) a * x1  + (long) b * y1 + c) != Long.signum((long) a * x2  + (long) b * y2 + c))
				cnt++;
		}
		println(cnt);
	}
}


import java.io.*;
import java.util.*;
public class CF284C
{
	static int ans=0;
	static long x1,y1,x2,y2;
	public static void solver(long a,long b,long c)
	{
		long x=a*x1+b*y1+c,y=a*x2+b*y2+c;
		if((x<0l && y>0l) || (x>0l && y<0l))
			ans++;
	}
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		/*------------------------------My Code starts here------------------------------*/
		int i=0,n;
		x1=in.nextLong();
		y1=in.nextLong();
		x2=in.nextLong();
		y2=in.nextLong();
		n=in.nextInt();
		for(;i<n;i++)
			solver(in.nextLong(), in.nextLong(), in.nextLong());
		out.println(ans);
		out.close();
		/*------------------------------The End------------------------------------------*/
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


import java.io.*;
import java.util.*;
public class CF284C
{
	static int ans=0,x1,y1,x2,y2;
	public static void solver(int a,int b,int c)
	{
		int x=a*x1+b*y1+c,y=a*x2+b*y2+c;
		if((x<0 && y>0) || (x>0 && y<0))
			ans++;
	}
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		/*------------------------------My Code starts here------------------------------*/
		int i=0,n;
		x1=in.nextInt();
		y1=in.nextInt();
		x2=in.nextInt();
		y2=in.nextInt();
		n=in.nextInt();
		for(;i<n;i++)
			solver(in.nextInt(), in.nextInt(), in.nextInt());
		out.println(ans);
		out.close();
		/*------------------------------The End------------------------------------------*/
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class cf1 {
	//static double inf=Double.MAX_VALUE;
	static double e=1e-9;
	static class point implements Comparable<point>{
		double x;double y;
		point(double a,double b){
			x=a;y=b;
		}
		@Override
		public int compareTo(point o) {
			if(this.x!=o.x) {
				if(this.x<o.x) {
					return -1;
				}
				else {
					return 1;
				}
			}
			if(this.y<o.y)return -1;
			return 1;
		}
	}
	static class line{
		double a;double b;double c;
		line(point p1,point p2){
			if (Math.abs(p1.x - p2.x)<e) {
				a = 1.0;b = 0.0;c = -p1.x;
				} else {
				a = -(double)(p1.y - p2.y) / (p1.x - p2.x);
				b = 1.0;
				c = -(double)(a * p1.x) - p1.y;
				}
		}
		line(point p,double m){
			if(Math.abs(m-inf)<e) {
				a=1.0;b=0.0;c=-p.x;
			}
			else {
				a=-m;b=1.0;c=-(a * p.x) - p.y;
			}
		}
		line(double a1,double b1,double c1){
			a=a1;b=b1;c=c1;
		}
		double getx(double y) {
			return -(b*y+c)/a;
		}
		double intersecty(line l2) {
			return (a*l2.c-l2.a*c)/(b*l2.a-a*l2.b);
		}
		double slope() {
			if(b==0.0) {
				return inf;
			}
			return -a/b;
		}
		double perpSlope() {
			double m=slope();
			if(Math.abs(m)<e) {
				return inf;
			}
			if(Math.abs(m-inf)<e) {
				return 0;
			}
			return -1/m;
		}
	}
	static double p1x;
	static double p2x;
	static double p3x;
	static double p4x;
	static double p1y;
	static double p2y;
	static double p3y;
	static double p4y;
	static void find(double x1,double y1,double r1,line l,double x2,double y2,double r2) {
		if(l.b==0.0) {
			p1y=Math.sqrt(r1*r1-((-l.c)-x1))+y1;
			p2y=-Math.sqrt(r1*r1-((-l.c)-x1))+y1;
			p3y=Math.sqrt(r2*r2-((-l.c)-x2))+y2;
			p4y=-Math.sqrt(r2*r2-((-l.c)-x2))+y2;
			p1x=p2x=p3x=p4x=x1;
		}
		else {
			double m=-l.a;double c=-l.c;
			double a1=m*m+1;
	        double b1=((-2.0*x1)+(2.0*m*(c-y1)));
	        double c1=(x1*x1)+(c-y1)*(c-y1)-(r1*r1);
	        double a2=m*m+1;
	        double b2=(-2.0*x2+2.0*m*(c-y2));
	        double c2=x2*x2+(c-y2)*(c-y2)-r2*r2;
	        p1x=(-b1+Math.sqrt(b1*b1-4.0*a1*c1))/(2.0*a1);
	        p2x=(-b1-Math.sqrt(b1*b1-4.0*a1*c1))/(2.0*a1);
	        p1y=m*p1x+c;
	        p2y=m*p2x+c;
	        p3x=(-b2+Math.sqrt(b2*b2-4.0*a2*c2))/(2.0*a2);
	        p4x=(-b2-Math.sqrt(b2*b2-4.0*a2*c2))/(2.0*a2);
	        p3y=m*p3x+c;
	        p4y=m*p4x+c;

		}
	}
	static void find(double x1,double y1,double r1,line l) {
		if(l.b==0.0) {
			p1y2=Math.sqrt(r1*r1-((-l.c)-x1))+y1;
			p2y2=-Math.sqrt(r1*r1-((-l.c)-x1))+y1;

			p1x2=p2x2=x1;
		}
		else {
			double m=-l.a;double c=-l.c;
			double a1=m*m+1;
	        double b1=((-2.0*x1)+(2.0*m*(c-y1)));
	        double c1=(x1*x1)+(c-y1)*(c-y1)-(r1*r1);

	        p1x2=(-b1+Math.sqrt(b1*b1-4.0*a1*c1))/(2.0*a1);
	        p2x2=(-b1-Math.sqrt(b1*b1-4.0*a1*c1))/(2.0*a1);
	        p1y2=m*p1x2+c;
	        p2y2=m*p2x2+c;

		}
	}
	static double p1x2=200000;
	static double p2x2=200000;
	static double p1y2=200000;
	static double p2y2=200000;
	static double distsq(point p1,point p2) {
		return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
	}
	static long inf=(long)1e17;
    public static void main(String[] args) throws Exception{
        MScanner sc = new MScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        point home=new point(sc.nextDouble(),sc.nextDouble());
        point uni=new point(sc.nextDouble(),sc.nextDouble());
        line dist=new line(home,uni);
        double s=dist.slope();
        int n=sc.nextInt();int ans=0;
        for(int i=0;i<n;i++) {
        	line l=new line(sc.nextDouble(),sc.nextDouble(),sc.nextDouble());
        	if(s!=l.slope()) {
        		double y=dist.intersecty(l);
        		double x;
        		if(dist.a==0) {
        			x=l.getx(y);
        		}
        		else {
        			x=dist.getx(y);
        		}
        		if(between(home,uni, x, y)) {
        			ans++;
        		}
        	}
        }
        pw.println(ans);
        //pw.printf("%.12f",centerx);pw.print(" ");
        //pw.printf("%.12f",+centery);pw.print(" ");
        //pw.printf("%.12f",dist1/2.0);
        pw.flush();
    }
    static boolean between(point p, point q,double x,double y)
	{
		return x < Math.max(p.x, q.x) + e && x + e > Math.min(p.x, q.x)
				&& y < Math.max(p.y, q.y) + e && y + e > Math.min(p.y, q.y);
	}
    static boolean insideCircle(double x1,double y1,double x2,double y2,double r) {
    	double dx =x1-x2, dy =y1-y2;
    	double Euc = dx * dx + dy * dy, rSq = r * r;
    	//System.out.println((Euc-rSq<=e)+" "+Euc+" "+rSq);
    	return Euc-rSq<=e ? true : false; }
    static class pair implements Comparable<pair>{
    	long y1;long y2;
    	pair(long x,long y){
    		y1=x;y2=y;
    	}
		@Override
		public int compareTo(pair o) {
			if(y1>o.y1)return 1;
			if(y1<o.y1)return -1;
			if(y2>o.y2)return 1;
			return -1;
		}
		public String toString() {
			return "("+y1+" "+y2+")";
		}
    }
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;

        public MScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}


import java.util.*;
import java.io.*;

public class A498 {

	public static void main(String[] args) throws Exception {
		int sx = i(), sy = i(), ex = i(), ey = i();

		int n = i();

		int cross = 0;
		for (int i = 0; i < n; i++) {
			int a = i(), b = i(), c = i();

			int s = (int)Math.signum(a * sx + b * sy + c);
			int e = (int)Math.signum(a * ex + b * ey + c);

			if (s != e) cross++;
		}

		out.println(cross);

		out.close();
	}

	static BufferedReader in;
	static StringTokenizer st = new StringTokenizer("");
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static {
		try {
			in = new BufferedReader(new FileReader("cf.in"));
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
		}
	}
	static void check() throws Exception {
		if (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
	}
	static int i() throws Exception {check(); return Integer.parseInt(st.nextToken());}
	static String s() throws Exception {check(); return st.nextToken();}
	static double d() throws Exception {check(); return Double.parseDouble(st.nextToken());}
	static long l() throws Exception {check(); return Long.parseLong(st.nextToken());}
}


import java.util.*;
import java.io.*;

public class A498 {

	public static void main(String[] args) throws Exception {
		long sx = i(), sy = i(), ex = i(), ey = i();

		long n = i();

		int cross = 0;
		for (int i = 0; i < n; i++) {
			long a = i(), b = i(), c = i();

			long s = (long)Math.signum(a * sx + b * sy + c);
			long e = (long)Math.signum(a * ex + b * ey + c);

			if (s != e) cross++;
		}

		out.println(cross);

		out.close();
	}

	static BufferedReader in;
	static StringTokenizer st = new StringTokenizer("");
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static {
		try {
			in = new BufferedReader(new FileReader("cf.in"));
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
		}
	}
	static void check() throws Exception {
		if (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
	}
	static int i() throws Exception {check(); return Integer.parseInt(st.nextToken());}
	static String s() throws Exception {check(); return st.nextToken();}
	static double d() throws Exception {check(); return Double.parseDouble(st.nextToken());}
	static long l() throws Exception {check(); return Long.parseLong(st.nextToken());}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemACrazyTown solver = new ProblemACrazyTown();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemACrazyTown {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x1 = in.readInt();
            long y1 = in.readInt();
            long x2 = in.readInt();
            long y2 = in.readInt();

            int n = in.readInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int a = in.readInt();
                int b = in.readInt();
                int c = in.readInt();
                long v1 = a * x1 + b * y1 + c;
                v1 /= Math.abs(v1);
                long v2 = a * x2 + b * y2 + c;
                v2 /= Math.abs(v2);
                if (v1 * v2 < 0) ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemACrazyTown solver = new ProblemACrazyTown();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemACrazyTown {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x1 = in.readInt();
            long y1 = in.readInt();
            long x2 = in.readInt();
            long y2 = in.readInt();

            int n = in.readInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int a = in.readInt();
                int b = in.readInt();
                int c = in.readInt();
                double v1 = a * x1 + b * y1 + c;
                double v2 = a * x2 + b * y2 + c;
                if (v1 * v2 < 0) ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main extends PrintWriter {
    BufferedReader in;
    StringTokenizer stok;
    final Random rand = new Random(31);
    final int inf = (int) 1e9;
    final long linf = (long) 1e18;

    List<Integer>[] g;
    int[] mt;
    boolean[] used;

    boolean try_kuhn(int v) {
        if (used[v]) return false;
        used[v] = true;
        for (int i = 0; i < g[v].size(); ++i) {
            int to = g[v].get(i);
            if (mt[to] == -1 || try_kuhn(mt[to])) {
                mt[to] = v;
                return true;
            }
        }
        return false;
    }

    public void solve() throws IOException {
        long x1 = nextLong();
        long y1 = nextLong();
        long x2 = nextLong();
        long y2 = nextLong();
        int n = nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            long a = nextLong();
            long b = nextLong();
            long c = nextLong();
            if (Long.signum(a * x1 + b * y1 + c) != Long.signum(a * x2 + b * y2 + c)) {
                ans++;
            }
        }
        println(ans);
    }

    public void run() {
        try {
            solve();
            close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(abs(-1));
        }
    }

    Main() throws IOException {
        super(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    Main(String s) throws IOException {
        super("".equals(s) ? "output.txt" : (s + ".out"));
        in = new BufferedReader(new FileReader("".equals(s) ? "input.txt" : (s + ".in")));
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ignored) {
        }
        new Main().run();
    }

    String next() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    int[] nextIntArray(int len) throws IOException {
        int[] a = new int[len];
        for (int i = 0; i < len; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    void shuffle(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int x = rand.nextInt(i + 1);
            int t = a[i];
            a[i] = a[x];
            a[x] = t;
        }
    }

    boolean nextPerm(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
            if (p[a] < p[a + 1])
                for (int b = p.length - 1; ; --b)
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
        return false;
    }

    <T> List<T>[] createAdjacencyList(int countVertex) {
        List<T>[] res = new List[countVertex];
        for (int i = 0; i < countVertex; i++) {
            res[i] = new ArrayList<T>();
        }
        return res;
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main extends PrintWriter {
    BufferedReader in;
    StringTokenizer stok;
    final Random rand = new Random(31);
    final int inf = (int) 1e9;
    final long linf = (long) 1e18;

    class Item {
        int a, id;

        public Item(int a, int id) {
            this.a = a;
            this.id = id;
        }
    }

    double vec(double x1, double y1, double x2, double y2, double x3, double y3) {
        return (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
    }

    public void solve() throws IOException {
        long x1 = nextLong();
        long y1 = nextLong();
        long x2 = nextLong();
        long y2 = nextLong();
        int n = nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            long a = nextLong();
            long b = nextLong();
            long c = nextLong();
            if ((y2 - y1) * b == (x1 - x2) * a) {
                continue;
            }
            double v1 = vec(0, -c * 1.0 / b, -c * 1.0 / a, 0, x1, y1);
            double v2 = vec(0, -c * 1.0 / b, -c * 1.0 / a, 0, x2, y2);
            if (Math.signum(v1) != Math.signum(v2)) {
                ans++;
            }
        }
        println(ans);
    }

    public void run() {
        try {
            solve();
            close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(abs(-1));
        }
    }

    Main() throws IOException {
        super(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    Main(String s) throws IOException {
        super("".equals(s) ? "output.txt" : (s + ".out"));
        in = new BufferedReader(new FileReader("".equals(s) ? "input.txt" : (s + ".in")));
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ignored) {
        }
        new Main().run();
    }

    String next() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    int[] nextIntArray(int len) throws IOException {
        int[] a = new int[len];
        for (int i = 0; i < len; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    void shuffle(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int x = rand.nextInt(i + 1);
            int t = a[i];
            a[i] = a[x];
            a[x] = t;
        }
    }

    boolean nextPerm(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
            if (p[a] < p[a + 1])
                for (int b = p.length - 1; ; --b)
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
        return false;
    }

    <T> List<T>[] createAdjacencyList(int countVertex) {
        List<T>[] res = new List[countVertex];
        for (int i = 0; i < countVertex; i++) {
            res[i] = new ArrayList<T>();
        }
        return res;
    }
}


// package Mathematical;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CrazyTown {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String line[]=br.readLine().split(" ");
        long x1=Long.parseLong(line[0]);
        long y1=Long.parseLong(line[1]);
        line=br.readLine().split(" ");
        long x2=Long.parseLong(line[0]);
        long y2=Long.parseLong(line[1]);
        int n=Integer.parseInt(br.readLine());
        int ans=0;
        for(int i=1;i<=n;i++){
            line=br.readLine().split(" ");
            long a=Long.parseLong(line[0]);
            long b=Long.parseLong(line[1]);
            long c=Long.parseLong(line[2]);
            long op1=a*x1+b*y1+c;
            long op2=a*x2+b*y2+c;
            if(op1>0&&op2<0){
                ans++;
            }
            else if(op1<0&&op2>0){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


import java.util.Scanner;

public class Crazy_Town {
	static double eps=1e-9;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Point home=new Point(sc.nextDouble(),sc.nextDouble());
		Point uni=new Point(sc.nextDouble(),sc.nextDouble());
		int roads=sc.nextInt();
//		Line[]lines=new Line[roads];
		int count=0;
		for(int i=0;i<roads;i++) {
			Line l=new Line(sc.nextDouble(),sc.nextDouble(),sc.nextDouble());
			if(l.is_dif(home, uni))
				count++;

		}
		System.out.println(count);
	}
static class Point{
	double x,y;
	Point(double a,double b){
		x=a;y=b;
	}
	double cross(Point a) {
		return x*a.y-y*a.x;
	}

	double direction(Point a,Point b) {
		double tx=-a.x;
		double ty=-a.y;
		Point t=new Point(x+tx,y+ty);
		return t.cross(new Point(b.x+tx,b.y+ty));
	}

}
static class Line {
	double a,b,c;
	Line (double x,double y,double z){
		a=x;b=y;c=z;
	}
	double solve(Point p) {
		return p.x*a+p.y*b+c;
	}
	boolean is_dif(Point a,Point b) {
		return (solve(a)*solve(b)<0);
	}

}

}


import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    int y = in.nextInt();
    int xx = in.nextInt();
    int yy = in.nextInt();
    int n = in.nextInt();
    int res = 0;
    while (n-->0) {
      int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      long d = (long) a * x + (long) b * y + c;
      long dd = (long) a * xx + (long) b * yy + c;
      if (d > 0 && dd < 0 || d < 0 && dd > 0) {
        ++res;
      }
    }
    System.out.println(res);
  }
}


import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    int y = in.nextInt();
    int xx = in.nextInt();
    int yy = in.nextInt();
    int n = in.nextInt();
    int res = 0;
    while (n-->0) {
      int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      long d = (long) a * x + (long) b * y + c;
      long dd = (long) a * xx + (long) b * yy + c;
      if (d * dd < 0) {
        ++res;
      }
    }
    System.out.println(res);
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTown {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
		line line=new line(x1,y1,x2,y2);
		int n=sc.nextInt();
		line [] lines=new line[n];
		for(int i=0;i<n;i++)
			lines[i]=new line(sc.nextInt(),sc.nextInt(),sc.nextInt());
		int ans=0;
		for(line l:lines)
		{
			if(line.isIntersecting(l))
				ans++;
		}
		System.out.println(ans);

	}

}
class point
{
	static double EPS=1e-8;
	int  x;
	int  y;

	public point (int a,int  b)
	{
		x=a;
		y=b;
	}

	public String toString()
	{
		return x+" "+y;
	}
}
class line
{

	static double EPS=1e-6;
	double a;double b;double c;
	int x1;int y1;int x2;int y2;
	public line(int x1,int y1,int x2,int y2)
	{
		if(x1==x2)
		{
			a=1.0;b=0.0;c=-x1; //Horizontal

		}
		else
		{
			double dx=x2-x1;double dy=y2-y1;
			b=1;a=-dy/dx;
			c=-a*x1-y1;
		}
		this.x1=x1;this.x2=x2;this.y1=y1;this.y2=y2;

	}
	public boolean isIntersecting(line l)
	{
		if(this.isParallel(l))
			return false;

		double x=l.pointOfIntersection(this);
		double y=0;
		if(b!=0)
		{
			y=-a*x-c;
		}
		else
		{
			y=-l.a*x-l.c;
		}

		return onSegment(x1,y1,x2,y2,x,y);
	}
	public static boolean onSegment(int x1,int y1,int x2,int y2,double x,double y)
	{
		int maxX=Math.max(x1, x2);
		int minX=Math.min(x1, x2);
		int maxY=Math.max(y1, y2);
		int minY=Math.min(y1, y2);

		if(x>minX-EPS&& x<maxX+EPS && y>minY-EPS && y<maxY+EPS)
			return true;
		else
			return false;

	}
	public boolean isParallel(line l)
	{
		return Math.abs(b-l.b)<EPS && Math.abs(a-l.a)<EPS;

	}
	public double pointOfIntersection(line l)
	{
		return (this.c-l.c)/(l.a-this.a);
	}
	public line(double x,double y,double z)
	{
		if(y==0)
		{
			c=z/x;a=1;b=0;
		}
		else
		{

			c=z/y;
			b=1;
			a=x/y;

		}

	}

	public String toString()
	{
		return a+" "+c;
	}

}
class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTown {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
		line line=new line(x1,y1,x2,y2);
		int n=sc.nextInt();
		line [] lines=new line[n];
		for(int i=0;i<n;i++)
			lines[i]=new line(sc.nextInt(),sc.nextInt(),sc.nextInt());
		int ans=0;
		for(line l:lines)
		{
			if(line.isIntersecting(l))
				ans++;
		}
		System.out.println(ans);

	}

}
class point
{
	static double EPS=1e-8;
	int  x;
	int  y;

	public point (int a,int  b)
	{
		x=a;
		y=b;
	}

	public String toString()
	{
		return x+" "+y;
	}
}
class line
{

	static double EPS=1e-8;
	double a;double b;double c;
	int x1;int y1;int x2;int y2;
	public line(int x1,int y1,int x2,int y2)
	{
		if(x1==x2)
		{
			a=1.0;b=0.0;c=-x1; //Horizontal

		}
		else
		{
			double dx=x2-x1;double dy=y2-y1;
			b=1;a=-dy/dx;
			c=-a*x1-y1;
		}
		this.x1=x1;this.x2=x2;this.y1=y1;this.y2=y2;

	}
	public boolean isIntersecting(line l)
	{
		if(this.isParallel(l))
			return false;

		double x=l.pointOfIntersection(this);
		double y=0;
		if(b!=0)
		{
			y=-a*x-c;
		}
		else
		{
			y=-l.a*x-l.c;
		}

		return onSegment(x1,y1,x2,y2,x,y);
	}
	public static boolean onSegment(int x1,int y1,int x2,int y2,double x,double y)
	{
		int maxX=Math.max(x1, x2);
		int minX=Math.min(x1, x2);
		int maxY=Math.max(y1, y2);
		int minY=Math.min(y1, y2);

		if(x>minX-EPS&& x<maxX+EPS && y>minY-EPS && y<maxY+EPS)
			return true;
		else
			return false;

	}
	public boolean isParallel(line l)
	{
		return Math.abs(b-l.b)<EPS && Math.abs(a-l.a)<EPS;

	}
	public double pointOfIntersection(line l)
	{
		return (this.c-l.c)/(l.a-this.a);
	}
	public line(double x,double y,double z)
	{
		if(y==0)
		{
			c=z/x;a=1;b=0;
		}
		else
		{

			c=z/y;
			b=1;
			a=x/y;

		}

	}

	public String toString()
	{
		return a+" "+c;
	}

}
class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTown {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
		line line=new line(x1,y1,x2,y2);
		int n=sc.nextInt();
		line [] lines=new line[n];
		for(int i=0;i<n;i++)
			lines[i]=new line(sc.nextInt(),sc.nextInt(),sc.nextInt());
		int ans=0;
		for(line l:lines)
		{
			if(line.isIntersecting(l))
				ans++;
		}
		System.out.println(ans);

	}

}
class point
{
	static double EPS=1e-8;
	int  x;
	int  y;

	public point (int a,int  b)
	{
		x=a;
		y=b;
	}

	public String toString()
	{
		return x+" "+y;
	}
}
class line
{

	static double EPS=1e-9;
	double a;double b;double c;
	int x1;int y1;int x2;int y2;
	public line(int x1,int y1,int x2,int y2)
	{
		if(x1==x2)
		{
			a=1.0;b=0.0;c=-x1; //Horizontal

		}
		else
		{
			double dx=x2-x1;double dy=y2-y1;
			b=1;a=-dy/dx;
			c=-a*x1-y1;
		}
		this.x1=x1;this.x2=x2;this.y1=y1;this.y2=y2;

	}
	public boolean isIntersecting(line l)
	{
		if(this.isParallel(l))
			return false;

		double x=l.pointOfIntersection(this);
		double y=0;
		if(b!=0)
		{
			y=-a*x-c;
		}
		else
		{
			y=-l.a*x-l.c;
		}

		return onSegment(x1,y1,x2,y2,x,y);
	}
	public static boolean onSegment(int x1,int y1,int x2,int y2,double x,double y)
	{
		int maxX=Math.max(x1, x2);
		int minX=Math.min(x1, x2);
		int maxY=Math.max(y1, y2);
		int minY=Math.min(y1, y2);

		if(x>minX-EPS&& x<maxX+EPS && y>minY-EPS && y<maxY+EPS)
			return true;
		else
			return false;

	}
	public boolean isParallel(line l)
	{
		return Math.abs(b-l.b)<EPS && Math.abs(a-l.a)<EPS;

	}
	public double pointOfIntersection(line l)
	{
		return (this.c-l.c)/(l.a-this.a);
	}
	public line(double x,double y,double z)
	{
		if(y==0)
		{
			c=z/x;a=1;b=0;
		}
		else
		{

			c=z/y;
			b=1;
			a=x/y;

		}

	}

	public String toString()
	{
		return a+" "+c;
	}

}
class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTownFinal {
static double max=1e7;
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
		lineSegment line=new lineSegment(x1,y1,x2,y2);
		int n=sc.nextInt();
		lineSegment [] lines=new lineSegment[n];
		for(int i=0;i<n;i++)
		{
			double a=sc.nextInt();double b=sc.nextInt();double c=sc.nextInt();
			point p1,p2;
			if(b==0)
			{
				p1=new point (-c/a,max);
				p2=new point (-c/a,-max);
			}
			else if(a==0)
			{
				p1=new point (max,-c/b);
				p2=new point (-max,-c/b);

			}
			else
			{
				double y=(-a*max-c)/b;
				p1=new point (max,y);
				y=a*max-c;
				p2=new point(-max,y/b);
			}
			lines[i]=new lineSegment(p1,p2);

		}
		int ans=0;
		for(lineSegment l:lines)
		{
			if(line.isIntersecting(l))
				ans++;
		}
		System.out.println(ans);

	}

}
class point
{
	static double EPS=1e-9;
	double  x;
	double  y;

	public point (double d,double  e)
	{
		x=d;
		y=e;
	}

	public String toString()
	{
		return x+" "+y;
	}
}

class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}
class lineSegment
{
	static double EPS=1e-9;

	point p1;
	point p2;

	public static double direction(point p,point q,point r)
	{
		point a=new point ((q.x-p.x),(q.y-p.y));
		point b=new point ((r.x-p.x),(r.y-p.y));
		return cross(b,a);
	}
	public static double cross(point p,point q)
	{
		return p.x*q.y-q.x*p.y;
	}
	public String toString ()
	{
		return "x1= "+p1.x+" y1 = "+p1.y+" x2= "+p2.x+" y2= "+p2.y;
	}
	public lineSegment(int x1,int y1,int x2,int y2)

	{
			p2=new point (x2,y2);
			p1=new point (x1,y1);

	}
	public lineSegment(point p1, point p2) {
		{
			this.p1=p1;this.p2=p2;
		}
	}

	public boolean isIntersecting(lineSegment l)
	{
		double d1=direction(l.p1,l.p2,this.p1);
		double d2=direction(l.p1,l.p2,this.p2);
		if(d1>0 && d2<0)
			return true;
		if(d1<0 && d2>0)
			return true;
		if(Math.abs(d1)<EPS && isOnSegment(l,this.p1))
			return true;
		if(Math.abs(d2)<EPS && isOnSegment(l,this.p2))
			return true;

		return false;

	}
	public static boolean isOnSegment (lineSegment l,point p)
	{
		if(p.x<=Math.max(l.p1.x, l.p2.x)+EPS &&p.x>=Math.min(l.p1.x, l.p2.x)-EPS && p.y>=l.p2.y-EPS && p.y<=l.p1.y+EPS)
			return true;
		return false;
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTown {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
		line line=new line(x1,y1,x2,y2);
		int n=sc.nextInt();
		line [] lines=new line[n];
		for(int i=0;i<n;i++)
			lines[i]=new line(sc.nextInt(),sc.nextInt(),sc.nextInt());
		int ans=0;
		for(line l:lines)
		{
			if(line.isIntersecting(l))
				ans++;
		}
		System.out.println(ans);

	}

}
class point
{
	static double EPS=1e-9;
	int  x;
	int  y;

	public point (int a,int  b)
	{
		x=a;
		y=b;
	}

	public String toString()
	{
		return x+" "+y;
	}
}
class line
{

	static double EPS=1e-9;
	double a;double b;double c;
	int x1;int y1;int x2;int y2;
	public line(int x1,int y1,int x2,int y2)
	{
		if(x1==x2)
		{
			a=1.0;b=0.0;c=-x1; //Horizontal

		}
		else
		{
			double dx=x2-x1;double dy=y2-y1;
			b=1;a=-dy/dx;
			c=-a*x1-y1;
		}
		this.x1=x1;this.x2=x2;this.y1=y1;this.y2=y2;

	}
	public boolean isIntersecting(line l)
	{
		if(this.isParallel(l))
			return false;

		double x=l.pointOfIntersection(this);
		double y=0;
		if(b!=0)
		{
			y=-a*x-c;
		}
		else
		{
			y=-l.a*x-l.c;
		}

		return onSegment(x1,y1,x2,y2,x,y);
	}
	public static boolean onSegment(int x1,int y1,int x2,int y2,double x,double y)
	{
		int maxX=Math.max(x1, x2);
		int minX=Math.min(x1, x2);
		int maxY=Math.max(y1, y2);
		int minY=Math.min(y1, y2);

		if(x>minX-EPS&& x<maxX+EPS && y>minY-EPS && y<maxY+EPS)
			return true;
		else
			return false;

	}
	public boolean isParallel(line l)
	{
		return Math.abs(b-l.b)<EPS && Math.abs(a-l.a)<EPS;

	}
	public double pointOfIntersection(line l)
	{
		return (this.c-l.c)/(l.a-this.a);
	}
	public line(double x,double y,double z)
	{
		if(y==0)
		{
			c=z/x;a=1;b=0;
		}
		else
		{

			c=z/y;
			b=1;
			a=x/y;

		}

	}

	public String toString()
	{
		return a+" "+c;
	}

}
class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CrazyTown {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt(),y1=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt();
		point start=new point (x1,y1);
		point end=new point (x2,y2);
		line line=new line(start,end);
		int n=sc.nextInt();
		line [] lines=new line[n];
		for(int i=0;i<n;i++)
			lines[i]=new line(sc.nextInt(),sc.nextInt(),sc.nextInt());
		int ans=0;
		for(line l:lines)
		{
			if(line.isIntersecting(l))
				ans++;
		}
		System.out.println(ans);

	}

}
class point
{
	static double EPS=1e-9;
	int  x;
	int  y;

	public point (int a,int  b)
	{
		x=a;
		y=b;
	}

	public String toString()
	{
		return x+" "+y;
	}
}
class line
{

	point p1;point p2;static double EPS=1e-9;
	double a;double b;double c;
	public line(point p1,point p2)
	{
		if(p1.x==p2.x)
		{
			a=1.0;b=0.0;c=-p1.x;

		}
		else
		{
			b=1;a=-((double)(p2.y-p1.y)/(double)(p2.x-p1.x));
			c=a*p1.x+p1.y;
		}
		this.p1=p1;this.p2=p2;
	}
	public boolean isIntersecting(line l)
	{
		if(this.isParallel(l))
			return false;

		double x=l.pointOfIntersection(this);
		double y=0;
		if(a==0)
		{
			y=-c;
		}
		else if(b==0)
		{
			if(l.a==0)
				y=-l.c;
			else
				y=-l.a*x-l.c;
		}
		else
			y=-a*x-c;

		return onSegment(p1.x,p1.y,p2.x,p2.y,x,y);
	}
	public static boolean onSegment(int x1,int y1,int x2,int y2,double x,double y)
	{
		int maxX=Math.max(x1, x2);
		int minX=Math.min(x1, x2);
		int maxY=Math.max(y1, y2);
		int minY=Math.min(y1, y2);
		if(x>minX-EPS&& x<maxX+EPS && y>minY-EPS && y<maxY+EPS)
			return true;
		else
			return false;

	}
	public boolean isParallel(line l)
	{
		return Math.abs(b-l.b)<EPS && Math.abs(a-l.a)<EPS;

	}
	public double pointOfIntersection(line l)
	{
		if(a==0 || b==0)
			return -c;
		if(l.a==0 || l.b==0)
			return -l.c;

		return (c-l.c)/(this.a-a);
	}
	public line(double x,double y,double z)
	{
		if(y==0)
		{
			c=z/x;a=1;b=0;
		}
		else
		{

			c=z/y;
			b=1;
			a=x/y;

		}

	}
	public double solveForX(double y)
	{
		return (c-y)/a;
	}
	public String toString()
	{
		return a+" "+c;
	}

}
class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}