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.Scanner;


public class A {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Vector start = new Vector(sc.nextDouble(),sc.nextDouble());
		Vector end = new Vector(sc.nextDouble(),sc.nextDouble());
		Line path = new Line(start,end);
		int N = sc.nextInt();
		int ans = 0;
		for(int a=0;a<N;a++){
			double A = sc.nextDouble();
			double B = sc.nextDouble();
			double C = sc.nextDouble();
			double res1 = A*start.x+B*start.y+C;
			double res2 = A*end.x+B*end.y+C;
			if(res1<0&&res2>0)ans++;
			if(res1>0&&res2<0)ans++;
		}
		System.out.println(ans);
	}

	private static int magic(Vector A, Vector B, Vector P) {
		double d = (P.x-A.x)*(B.y-A.y)-(P.y-A.y)*(B.x-A.x);
		if(d<0)return -1;
		if(d>0)return 1;
		return 0;
	}

	static class Vector {
		final double x, y, z;
		static final double eps = 1e-10;

		public Vector(double x, double y, double z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public Vector(double x, double y) {
			this(x, y, 0);
		}

		public Vector(Vector AA, Vector BB) {
			Vector temp = AA.sub(BB);
			this.x=temp.x;
			this.y=temp.y;
			this.z=temp.z;
			
		}

		public double mag2() {
			return this.dot(this);
		}

		public double mag() {
			return Math.sqrt(this.mag2());
		}

		public Vector add(Vector that) {
			return new Vector(this.x + that.x, this.y + that.y, this.z + that.z);
		}

		public Vector sub(Vector that) {
			return new Vector(this.x - that.x, this.y - that.y, this.z - that.z);
		}

		public double dist2(Vector that) {
			return this.sub(that).mag2();
		}

		public double dist(Vector that) {
			return this.sub(that).mag();
		}

		public double dot(Vector that) {
			return this.x * that.x + this.y * that.y + this.z * that.z;
		}

		public double cross2d(Vector that) {
			return this.x * that.y - this.y * that.x;
		}

		public Vector cross(Vector that) {
			return new Vector(this.y * that.z - this.z * that.y,
							  this.z * that.x - this.x * that.z,
							  this.x * that.y - this.y * that.x);
		}
		
		public Vector scale(double s) {
			return new Vector(this.x*s, this.y*s, this.z*s);
		}
		
		public Vector normalize() {
			return scale(1/this.mag());
		}
		
		public double angle(Vector that) {
			return Math.atan2(this.cross(that).mag(), this.dot(that));
		}
		
		public double angle2d(Vector that) {
			return this.angle(that, new Vector(0, 0, 1));
		}
		
		public double angle(Vector that, Vector up) {
			double sign = Math.signum(this.cross(that).dot(up));
			return sign*this.angle(that);
		}
		
		public Vector project(Vector that) {
			return that.scale(this.dot(that)/that.dot(that));
		}
		
		public Vector rotate2D(double theta){ //radians
			double px = x * Math.cos(theta) - y * Math.sin(theta); 
			double py = x * Math.sin(theta) + y * Math.cos(theta);
			return new Vector(px,py);
		}

		public static double det(Vector v1, Vector v2, Vector v3){
			double aMul =	v2.y * v3.z - v3.y * v2.z;
			double bMul =	v1.y * v3.z - v3.y * v1.z;
			double cMul =	v1.y * v2.z - v2.y * v1.z;
			return aMul * v1.x + bMul * v2.x + cMul * v3.x;
		}
		public String toString(){
			return this.x+" "+this.y;
		}
	}
	static class Line {
		final Vector s, e, dir;
		static final double eps = 1e-10;
		
		public Line(Vector s, Vector e) {
			this.s = s;
			this.e = e;
			this.dir = e.sub(s);
		}
		
		public Vector closestPoint(Vector v) {
			double t = v.sub(s).project(dir).mag()/dir.mag();
			return this.getPoint(t); // bound t:[0,1] for segment
		}
		
		public double distance(Vector v) {
			return closestPoint(v).sub(v).mag();
		}
		
		public double distance(Line that) {
			double top = Math.abs(that.s.sub(this.s).dot(this.dir.cross(that.dir)));
			double bot = this.dir.cross(that.dir).mag();
			if(bot < eps) return this.distance(that.s); // Parallel
			return top/bot;
		}
		
		public Vector intersect(Line that) {
			Vector w = this.s.sub(that.s);
			double a = this.dir.dot(this.dir);
			double b = this.dir.dot(that.dir);	
			double c = that.dir.dot(that.dir);
			double d = this.dir.dot(w);
			double e = that.dir.dot(w);
			
			double bot = a*c-b*b;
			if(Math.abs(bot) < eps) return null; // Parallel
			double t1 = (b*e-c*d)/bot; // bound t1:[0,1] for segment
			double t2 = (a*e-b*d)/bot; // bound t2:[0,1] for segment
			if(t1<eps)return null;
			if(t1-1.0>eps)return null;
//			if(t2<eps)return null;
//			if(t2-1.0>eps)return null;
			Vector p1 = this.getPoint(t1);
			Vector p2 = that.getPoint(t2);
			if(p1.dist(p2) > eps) return null; // No intersection
			return p1;
		}
		
		// bound t:[0,1] for line segments
		public Vector getPoint(double t) {
			return dir.scale(t).add(s);
		}
		
	}


}
