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.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;
 public   class Main {
    static class Reader
    {
    BufferedReader r;
    StringTokenizer str;
    Reader()
    {
    r=new BufferedReader(new InputStreamReader(System.in));
    }
    Reader(String fileName) throws FileNotFoundException
    {
    r=new BufferedReader(new FileReader(fileName));
    }
    public String getNextToken() throws IOException
    {
    if(str==null||!str.hasMoreTokens())
    {
    str=new StringTokenizer(r.readLine());
    }
    return str.nextToken();
    }
    public int nextInt() throws IOException
    {
    return Integer.parseInt(getNextToken());
    }
    public long nextLong() throws IOException
    {
    return Long.parseLong(getNextToken());
    }
    public double nextDouble() throws IOException
    {
    return Double.parseDouble(getNextToken());
    }
    public String nextString() throws IOException
    {
    return getNextToken();
    }
    public int[] intArray(int n) throws IOException
    {
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            a[i]=nextInt();
        
        return a;
        
    }
    public long[] longArray(int n) throws IOException
    {
        long a[]=new long[n];
        for(int i=0;i<n;i++)
            a[i]=nextLong();
        
        return a;
        
    }
    public String[] stringArray(int n) throws IOException
    {
        String a[]=new String[n];
        for(int i=0;i<n;i++)
            a[i]=nextString();
        
        return a;
        
    }
    public int gcd(int a, int b) {
if(b == 0){
return a;
}
return gcd(b, a%b);
}
    }
  
   
    public static void main(String args[]) throws IOException{
    
   
       Reader r=new Reader();
       PrintWriter pr=new PrintWriter(System.out,false);
 int x1=r.nextInt();
 int y1=r.nextInt();
 int x2=r.nextInt();
 int y2=r.nextInt();
 int n=r.nextInt();
 double A1 = y2-y1;
double B1 = x1-x2;
 double C1=(A1*x1)+(B1*y1);
 
 int count=0;
 for(int i=0;i<n;i++)
 {
     
     double A2=r.nextDouble();
     double B2=r.nextDouble();
     double C2=r.nextDouble();
     C2=-1*C2;
     double det = A1*B2 - A2*B1;
    if(det == 0){
        
    }else{
        double x = ((B2*C1) - (B1*C2))/det;
        double y = ((A1*C2) - (A2*C1))/det;
       
        
        
                
        if(Math.min(x1,x2)<=x&&x<=Math.max(x1,x2)&&Math.min(y1,y2)<=y&&y<=Math.max(y1,y2))
        {
            
        count++;    
        }
        
    }

             
             
     
     
     
 }
 
     pr.println(count);    
 
 
      
       pr.flush();
       pr.close();
    }


 } 

