Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the point where at least two different roads intersect.

Your home is located in one of the blocks. Today you need to get to the University, also located in some block. In one step you can move from one block to another, if the length of their common border is nonzero (in particular, this means that if the blocks are adjacent to one intersection, but have no shared nonzero boundary segment, then it are not allowed to move from one to another one in one step).

Determine what is the minimum number of steps you have to perform to get to the block containing the university. It is guaranteed that neither your home nor the university is located on the road.

Input

The first line contains two space-separated integers x1, y1 ( - 106 ≤ x1, y1 ≤ 106) — the coordinates of your home.

The second line contains two integers separated by a space x2, y2 ( - 106 ≤ x2, y2 ≤ 106) — the coordinates of the university you are studying at.

The third line contains an integer n (1 ≤ n ≤ 300) — the number of roads in the city. The following n lines contain 3 space-separated integers ( - 106 ≤ ai, bi, ci ≤ 106; |ai| + |bi| > 0) — the coefficients of the line aix + biy + ci = 0, defining the i-th road. It is guaranteed that no two roads are the same. In addition, neither your home nor the university lie on the road (i.e. they do not belong to any one of the lines).

Output

Output the answer to the problem.

Examples

Input

1 1
-1 -1
2
0 1 0
1 0 0


Output

2


Input

1 1
-1 -1
3
1 0 0
0 1 0
1 1 -3


Output

2

Note

Pictures to the samples are presented below (A is the point representing the house; B is the point representing the university, different blocks are filled with different colors):

<image> <image>
import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.math.MathContext;
import java.text.DecimalFormat;
import java.text.Format;

import static java.lang.Math.*;
import static java.util.Arrays.*;
 
 
 
public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		Printer out = new Printer(System.out);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

 
static class TaskA {
	//public ArrayList<Integer> ar;
	public boolean[] bs;
	
  // GCD && LCM 
	 long gcd(long a ,long b){return b == 0 ? a : gcd(b , a % b);}
	 long lcm(long a , long b){return a*(b/gcd(a, b));}
	
  // Sieve of erothenese
	void sieve(int UB){
	//	ar = new ArrayList();
		bs = new boolean[UB+1];
		bs[0] = bs[1] = true;
		for(int i = 2; i*i <= UB; i++){
			if(!bs[i]){
				for(int j = i*i ; j <= UB ; j += i)
					bs[j] = true;
			}
		}
		/* for(int i = 2; i <= UB; i++){
		      if(!bs[i])ar.add(i);
		}*/
	}
	
	
	
	
	
	
	
	
	/*          SOLUTION  IS RIGHT HERE     */
	public void solve(int testNumber, InputReader in, Printer out) throws IOException{
		 // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 // Scanner sc = new Scanner(System.in);
		
		
		long x1 = in.nextInt() ,
			y1 = in.nextInt() ,
			x2 = in.nextInt() ,
			y2 = in.nextInt() ;
		
		int n = in.nextInt() ;
		int count = 0;
		while(n-->0){
			long a = in.nextInt(),
				b = in.nextInt(),
				c = in.nextInt();
			long one = a*x1 + b*y1 + c;
			long two = a*x2 + b*y2 + c;
			if((one >= 0 && two <= 0) || (one <= 0 && two >= 0))
				++count;
		}
		out.println(count);
	 }




}
  
  
 // ||||||| INPUT READER ||||||||
 static class InputReader {
	private byte[] buf = new byte[2048];
	private int index;
	private int total;
	private InputStream in;
	
	public InputReader(InputStream stream){
		in = stream;
	}
	
	public int scan() throws IOException{
		if(total < 0)
			throw new InputMismatchException();
		if(index >= total){
			index = 0; 
			total = in.read(buf);
			if(total <= 0)
				return -1;
		}
		return buf[index++];
	}
	public long scanlong() throws IOException{
		long integer = 0;
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		int neg = 1;
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n)){
			if(n >= '0' && n <= '9'){
				integer *= 10;
				integer += n - '0';
				n = scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	
	private int scanInt() throws IOException {
		int integer = 0;
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		int neg = 1;
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n)){
			if(n >= '0' && n <= '9'){
				integer *= 10;
				integer += n - '0';
				n = scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	
	public double scandouble() throws IOException{
		double doubll = 0;
		int n = scan();
		int neg = 1;
		while(isWhiteSpace(n))
			n = scan();
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n) && n != '.'){
			if(n >= '0' && n <= '9'){
				doubll *= 10;
				doubll += n - '0';
				n = scan();
			}
		}
		if(n == '.'){
			n = scan();
			double temp = 1;
			while(!isWhiteSpace(n)){
				if(n >= '0' && n <= '9'){
					temp /= 10;
					doubll += (n - '0')*temp;
					n = scan();
				}
			}
		}
		return neg*doubll;
	}
	
	private float scanfloat() throws IOException {
		float doubll = 0;
		int n = scan();
		int neg = 1;
		while(isWhiteSpace(n))
			n = scan();
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n) && n != '.'){
			if(n >= '0' && n <= '9'){
				doubll *= 10;
				doubll += n - '0';
				n = scan();
			}
		}
		if(n == '.'){
			n = scan();
			double temp = 1;
			while(!isWhiteSpace(n)){
				if(n >= '0' && n <= '9'){
					temp /= 10;
					doubll += (n - '0')*temp;
					n = scan();
				}
			}
		}
		return neg*doubll;
	}
	public String scanstring() throws IOException{
		StringBuilder sb = new StringBuilder();
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		while(!isWhiteSpace(n)){
			sb.append((char)n);
			n = scan();
		}
		return sb.toString();
	}
	
	
	public boolean isWhiteSpace(int n){
		if(n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
			return true;
		return false;
	}
/// Input module 	
	
	public int nextInt() throws IOException{
	  return scanInt();
	}
	
	public long nextLong() throws IOException{
		  return  scanlong();
		}
	
	public double nextDouble() throws IOException{
		  return  scandouble();
		}
	
	public float nextFloat() throws IOException{
		  return scanfloat();
		}

	public String next() throws IOException{
		return scanstring();
	}
}


// output writer
static class Printer{
	private final BufferedWriter bw;
	public Printer(OutputStream out){
		bw = new BufferedWriter(new OutputStreamWriter(out));
	}
	
    public void print(Object...objects) throws IOException{
    	for(int i = 0; i < objects.length; i++){
    		if(i != 0)
    			bw.append(' ');
    		bw.append(objects[i].toString());
    	}
    }
	public void print(String str) throws IOException{
		bw.append(str);
	}
	
	public void println(Object...objects) throws IOException {
		print(objects);
		bw.append("\n");
	}
	
	public void close() throws IOException{
		bw.close();
	}
	
	public void flush() throws IOException{
		bw.flush();
	}
}

static class IOUtils {
    public static int[] readIntArray(InputReader in, int size) throws IOException {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = in.nextInt();
        }
        return array;
    }
  }
}

