Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation a_{i}x + b_{i}y + c_{i} = 0, where a_{i} and b_{i} 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 x_1, y_1 ( - 10^6 ≤ x_1, y_1 ≤ 10^6) — the coordinates of your home.

The second line contains two integers separated by a space x_2, y_2 ( - 10^6 ≤ x_2, y_2 ≤ 10^6) — 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 ( - 10^6 ≤ a_{i}, b_{i}, c_{i} ≤ 10^6; |a_{i}| + |b_{i}| > 0) — the coefficients of the line a_{i}x + b_{i}y + c_{i} = 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]

Difficulty: competition

Starter code:

Solutions:
"""
Codeforces Contest 284 Div 1 Problem A

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

def main():
    x1,y1 = read()
    x2,y2 = read()
    n, = read()
    ct = 0
    for i in range(n):
        a,b,c = read()
        if (a*x1+b*y1+c)*(a*x2+b*y2+c) < 0: ct += 1
    print(ct)

#################################################### HELPERS



def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
val = 0
for i in range(int(input())):
    a, b, c = map(int, input().split())
    val += (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0
print(val)

#import sys
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')

def norm(a, b, c, d):
	if (b * c >= 0):
		return a * abs(c) <= abs(b) <= d * abs(c)
	return -a * abs(c) >= abs(b) >= -d * abs(c)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
a2 = y2 - y1
b2 = x1 - x2
c2 = 0 - a2 * x1 - b2 * y1
n = int(input())
ans = 0
for i in range(n):
	a1, b1, c1 = map(int, input().split())
	if (norm(min(x1, x2), (c2 * b1 - c1 * b2), (a1 * b2 - a2 * b1), max(x1, x2)) and norm(min(y1, y2), (c2 * a1 - c1 * a2), (a2 * b1 - a1 * b2), max(y1, y2))):
		ans += 1
print(ans)

line = input().split()
x1 = int(line[0])
y1 = int(line[1])
line = input().split()
x2 = int(line[0])
y2 = int(line[1])
n = int(input())
ans = 0
for i in range(n):
    line = input().split()
    a = int(line[0])
    b = int(line[1])
    c = int(line[2])
    d1 = (a * x1 + b * y1 + c)
    d2 = (a * x2 + b * y2 + c)
    if d1 * d2 < 0:
        ans += 1

print(ans)


ans = 0
read_line = lambda: [int(i) for i in input().split()]
x0, y0 = read_line()
x1, y1 = read_line()
n = int(input())
for i in range(n):
    a, b, c = read_line()
    ans += (a * x0 + b * y0 + c) * (a * x1 + b * y1 + c) < 0
print(ans)


x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
k = 0
n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
        k += 1
print(k)

def main():
    rdl = list(map(int,input().split()))
    x1,y1 = rdl
    rdl = list(map(int,input().split()))
    x2,y2 = rdl
    n = int(input())
    Steps = 0
    for i in range(n):
        rdl = list(map(int,input().split()))
        if rdl[1]*y1+rdl[0]*x1+rdl[2] > 0 and rdl[1]*y2+rdl[0]*x2+rdl[2] < 0:
            Steps += 1
        elif rdl[1]*y1+rdl[0]*x1+rdl[2] < 0 and rdl[1]*y2+rdl[0]*x2+rdl[2] > 0:
            Steps += 1
    print(Steps)
main()
            


read_line = lambda: [int(i) for i in input().split()]
x0, y0 = read_line()
x1, y1 = read_line()
print(sum((a * x0 + b * y0 + c) * (a * x1 + b * y1 + c) < 0 for a, b, c in (read_line() for i in range(int(input())))))


x1, y1 = list(map(float, input().split()))
x2, y2 = list(map(float, input().split()))
n = int(input())
ans = 0
for i in range(n):
    a, b, c = list(map(int, input().split()))
    if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
        ans += 1
print(ans)


x, y = map(int, input().split())
u, v = map(int, input().split())
s = 0
for i in range(int(input())):
    a, b, c = map(int, input().split())
    s += (a * x + b * y + c > 0) ^ (a * u + b * v + c > 0)
print(s)

#!/usr/bin/env python3

x, y = list(map(int, input().split()))
u, v = list(map(int, input().split()))
n = int(input())
s = 0
for i in range(n):
    a, b, c = list(map(int, input().split()))
    s += (a * x + b * y + c > 0) ^ (a * u + b * v + c > 0)
print(s)


x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))

ans = 0
for i in range(int(input())):
    a, b, c = list(map(int, input().split()))
    if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
        ans += 1

print(ans)


def input_split(f): return list(map(f, input().split()))


def main():
    x1, y1 = input_split(int)
    x2, y2 = input_split(int)
    n = int(input())
    count = 0
    for i in range(n):
        a, b, c = input_split(int)
        if (a*x1+b*y1+c) * (a*x2+b*y2+c) < 0:
            count+=1
    print(count)

main()


#!/usr/bin/env python3

x1, y1 = (int(x) for x in input().split())
x2, y2 = (int(x) for x in input().split())
n = int(input())
ans = 0
for i in range(n):
    a, b, c = (int(x) for x in input().split())
    point1 = a*x1 + b*y1 + c
    point2 = a*x2 + b*y2 + c
    if point1 * point2 < 0:
        ans += 1
print(ans)

x1, y1 = [int(x) for x in input().split()]
x2, y2 = [int(x) for x in input().split()]
n = int(input())
ans = 0
for i in range(n):
	a, b, c = [int(x) for x in input().split()]
	x = x1 * a + y1 * b + c
	x //= abs(x)
	y = x2 * a + y2 * b + c
	y //= abs(y)
	if x != y:
		ans += 1
print(ans)


x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
n = int(input())
r = 0
for i in range(n):
    q = list(map(int, input().split()))
    r = r + ((q[0]*x1+q[1]*y1+q[2])*(q[0]*x2+q[1]*y2+q[2])<0)
print(r)

a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=int(input())
d=[]
for i in range(c):d+=[list(map(int,input().split()))]
e=list([j[0]*a[0]+j[1]*a[1]+j[2]>0 for j in d])
f=list([j[0]*b[0]+j[1]*b[1]+j[2]>0 for j in d])
print(len(list([x for x in range(len(d)) if e[x]!=f[x]])))


a , b = list(map(int, input("").split(" ")))
c , d = list(map(int, input("").split(" ")))
dumb = int(input(""))
lines = []
for value in range(dumb):
    lines.append(input("").split(" "))
count = 0
check1 = 0
check2 = 0
for value in lines:
    if (int(value[0])*a + int(value[1])*b+int(value[2])>= 0):
        check1 = 1
    else:
        check1 = -1
    if(int(value[0])*c+int(value[1])*d+int(value[2])>=0):
        check2 = 1
    else:
        check2 = -1
    if check2 != check1:
        count = count + 1
print(count)


x, y = list(map(float, input().split(' ')))
x1, y1 = list(map(float, input().split(' ')))
n = int(input())
r = 0
for i in range(n):
    a, b, c = list(map(float, input().split(' ')))
    q1 = a * x + b * y + c
    q2 = a * x1 + b * y1 + c
    if (q1 > 0 and q2 < 0) or (q1 < 0 and q2 > 0):
        r += 1
print(r)


x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
n = int(input())
s = 0
for i in range(n):
    a,b,c = map(int,input().split())
    if ((((a * x1) + (b * y1) + c) * ((a * x2) + (b * y2) + c)) < 0):
        s = s + 1
print(s)

x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
n = int(input())
cost = 0
for i in range(n):
    a, b, c = list(map(int, input().split()))
    d1 = a * x1 + b * y1 + c
    d2 = a * x2 + b * y2 + c
    if d1 * d2 < 0: cost += 1
print(cost)


(x1, y1) = input().split(" ")
x1 = int(x1)
y1 = int(y1)
(x2, y2) = input().split(" ")
x2 = int(x2)
y2 = int(y2)
n = int(input())
lineslist = []
for i in range(n):
    (a, b, c) = input().split(" ")
    lineslist.append((int(a), int(b), int(c)))

def greaterThanLine(x, y, a, b, c):
    return a*x + b*y + c > 0

count = 0
for line in lineslist:
    (a, b, c) = line
    if greaterThanLine(x1, y1, a, b, c) ^ greaterThanLine(x2, y2, a, b, c):
        count += 1

print(count)


import re, sys, math, string, operator, functools, fractions, collections
from random import *
sys.setrecursionlimit(10**7)
dX= [-1, 1, 0, 0,-1, 1,-1, 1]
dY= [ 0, 0,-1, 1, 1,-1,-1, 1]
RI=lambda: list(map(int,input().split()))
RS=lambda: input().rstrip().split()
mod=1e9+7
#################################################
x1,y1 = RI()
x2,y2 = RI()
def sign(x):
    return x<0
n=RI()[0]
ans=0
for i in range(n):
    a,b,c=RI()
    if sign(a*x1+b*y1+c)!=sign(a*x2+b*y2+c):
        ans+=1
print(ans)


#!/usr/bin/env python3
import collections, itertools, functools, math

def value(a, b, c, x, y):
    return a*x + b*y + c

def sign(x):
    if x < 0:
        return -1
    if x == 0:
        return 0
    if x > 0:
        return 1

def solve():
    x1, y1 = list(map(int, input().split()))
    x2, y2 = list(map(int, input().split()))
    n = int(input())
    r = 0;
    for i in range(n):
        a, b, c = list(map(int, input().split()))
        s1 = value(a, b, c, x1, y1)
        s2 = value(a, b, c, x2, y2)
        if sign(s1) != sign(s2):
            r += 1
    return r


def __starting_point():
    print(solve())


__starting_point()

import sys

#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

def sign(a, b, c, x, y):
	value = a * x + b * y + c
	if value < 0:
		return -1
	if value == 0:
		return 0
	return 1

n, ans = int(input()), 0
for i in range(n):
	a, b, c = map(int, input().split())
	if sign(a, b, c, x1, y1) != sign(a, b, c, x2, y2):
		ans += 1
print(ans)