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]

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Geometry


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


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
num_sign_diff = 0
for road in range(n):
	(a, b, c) = map(int, input().split())
	pos1 = a * x1 + b * y1 + c > 0
	pos2 = a * x2 + b * y2 + c > 0
	if pos1 + pos2 == 1:
		num_sign_diff += 1
print(num_sign_diff)


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) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	n = int(input())
	r = 0
	for i in range(n):
		(a, b, c) = 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
print(solve())


import math

def get_n():
	return int(input())

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
(b_x, b_y) = get_int_vector()
(e_x, e_y) = get_int_vector()
n = get_n()
result = 0
for _ in range(n):
	(a_i, b_i, c_i) = get_int_vector()
	if (a_i * b_x + b_i * b_y + c_i) * (a_i * e_x + b_i * e_y + c_i) < 0:
		result += 1
print(result)


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)

def read(mode=2):
	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())


(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) = map(int, input().split())
(x1, y1) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	if (a * x + b * y + c) * (a * x1 + b * y1 + c) < 0:
		ans += 1
print(ans)


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


(x, y) = input().split()
(x, y) = [int(x), int(y)]
(a, b) = input().split()
(a, b) = [int(a), int(b)]
n = int(input())
counter = 0
for i in range(n):
	(p, q, r) = input().split()
	(p, q, r) = [int(p), int(q), int(r)]
	q1 = p * x + q * y + r
	q2 = p * a + q * b + r
	if q1 > 0 and q2 < 0 or (q1 < 0 and q2 > 0):
		counter += 1
print(counter)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
arr = []
for _ in range(n):
	(a, b, c) = map(int, input().split())
	arr.append((a, b, c))
res = 0
for i in arr:
	(a, b, c) = i
	if b != 0:
		y00 = -c / b
		y01 = -(a + c) / b
		s1 = x1 * (y01 - y00) - (y1 - y00)
		s2 = x2 * (y01 - y00) - (y2 - y00)
		if s1 < 0 < s2 or s1 > 0 > s2:
			res += 1
	else:
		x = -c / a
		if x1 < x < x2 or x1 > x > x2:
			res += 1
print(res)


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)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
summa = 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:
		summa += 1
print(summa)


(homex, homey) = (int(x) for x in input().split(' '))
(univx, univy) = (int(x) for x in input().split(' '))
n = int(input())
step = 0
for i in range(0, n):
	(a, b, c) = (int(x) for x in input().split(' '))
	homearea = a * homex + b * homey + c < 0
	univarea = a * univx + b * univy + c < 0
	if homearea != univarea:
		step += 1
print(step)


(xH, yH) = map(int, input().split())
(xU, yU) = map(int, input().split())
n = int(input())

def cross_product(a, b, c):
	v1 = a * xH + b * yH + c
	v2 = a * xU + b * yU + c
	return v1 < 0 and v2 > 0 or (v1 > 0 and v2 < 0)
res = 0
for _ in range(n):
	(a, b, c) = map(int, input().split())
	if cross_product(a, b, c):
		res += 1
print(res)


(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)


h = list(map(int, input().strip().split()))
u = list(map(int, input().strip().split()))
n = int(input())
count = 0
for i in range(n):
	(a, b, c) = list(map(int, input().strip().split()))
	t1 = a * h[0] + b * h[1] + c
	t2 = a * u[0] + b * u[1] + c
	if (t1 > 0) != (t2 > 0):
		count += 1
print(count)


(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)


from sys import stdin
R = lambda : map(int, stdin.readline().split())
(x1, y1) = R()
(x2, y2) = R()
ans = 0
for _ in range(int(input())):
	(a, b, c) = R()
	if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
		ans += 1
print(ans)


def getMinSteps(x1, y1, x2, y2, n, lines):
	min_steps = 0
	for i in range(n):
		a = lines[i][0]
		b = lines[i][1]
		c = lines[i][2]
		if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
			min_steps += 1
	return min_steps
(x1, y1) = [int(x) for x in input().split()]
(x2, y2) = [int(x) for x in input().split()]
n = int(input())
lines = []
for i in range(n):
	line = [int(x) for x in input().split()]
	lines.append((line[0], line[1], line[2]))
print(getMinSteps(x1, y1, x2, y2, n, lines))


(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()))
steps = 0
for i in int(input()) * '_':
	(a, b, c) = list(map(int, input().split()))
	if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
		steps += 1
print(steps)


from fractions import Fraction

def line_equation(pt1, pt2):
	return (pt1[1] - pt2[1], pt2[0] - pt1[0], pt1[0] * pt2[1] - pt1[1] * pt2[0])

def line_intersection(line1, line2):
	if line1[0] * line2[1] - line1[1] * line2[0] == 0:
		return (10 ** 18, 10 ** 18)
	return (Fraction(line1[1] * line2[2] - line1[2] * line2[1], line1[0] * line2[1] - line1[1] * line2[0]), Fraction(line1[2] * line2[0] - line1[0] * line2[2], line1[0] * line2[1] - line1[1] * line2[0]))

def is_between(pt1, pt2, mid):
	v1 = (pt1[0] - mid[0], pt1[1] - mid[1])
	v2 = (pt2[0] - mid[0], pt2[1] - mid[1])
	return v1[0] * v2[0] + v1[1] * v2[1] <= 0
(x1, y1) = list(map(int, input().split()))
(x2, y2) = list(map(int, input().split()))
line0 = line_equation((x1, y1), (x2, y2))
n = int(input())
ans = 0
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	(x, y) = line_intersection(line0, (a, b, c))
	if is_between((x1, y1), (x2, y2), (x, y)):
		ans += 1
print(ans)


(hx, hy) = map(int, input().split())
(ux, uy) = map(int, input().split())
n = int(input())
count = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	h = a * hx + b * hy + c
	u = a * ux + b * uy + c
	if h * u < 0:
		count += 1
print(count)


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()))))))


def getToU(hauseX, hauseY, uX, uY):
	nOfRoads = int(input())
	moves = 0
	for i in range(nOfRoads):
		road = list(map(int, input().split()))
		s = road[0] * hauseX + road[1] * hauseY + road[2]
		e = road[0] * uX + road[1] * uY + road[2]
		if s > 0 and e < 0 or (s < 0 and e > 0):
			moves += 1
	return moves
hause = list(map(int, input().split()))
university = list(map(int, input().split()))
print(getToU(hause[0], hause[1], university[0], university[1]))


h = input().split()
h[0] = int(h[0])
h[1] = int(h[1])
u = input().split()
u[0] = int(u[0])
u[1] = int(u[1])
count = 0
n = int(input())
for i in range(n):
	p = input().split()
	p[0] = int(p[0])
	p[1] = int(p[1])
	p[2] = int(p[2])
	hp = h[0] * p[0] + h[1] * p[1] + p[2]
	up = u[0] * p[0] + u[1] * p[1] + p[2]
	if hp > 0 and up < 0 or (hp < 0 and up > 0):
		count += 1
print(count)


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


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)


def read():
	return map(int, input().split())
(x1, y1) = read()
(x2, y2) = read()
(n,) = read()
ans = 0
for _ in range(n):
	(ai, bi, ci) = read()
	home = ai * x1 + bi * y1 + ci
	uni = ai * x2 + bi * y2 + ci
	if home // abs(home) * (uni // abs(uni)) < 0:
		ans += 1
print(ans)


(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)


(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)


(x, y) = map(float, input().split(' '))
(x1, y1) = map(float, input().split(' '))
n = int(input())
r = 0
for i in range(n):
	(a, b, c) = 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())
lines = []
for _ in range(n):
	(a, b, c) = map(int, input().split())
	lines.append((a, b, c))
ans = 0
for (a, b, c) in lines:
	if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0:
		ans += 1
print(ans)


def clockwise(x, y, a, b, c):
	return a * x + b * y + c < 0
(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
ans = 0
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if clockwise(x1, y1, a, b, c) != clockwise(x2, y2, a, b, c):
		ans += 1
print(ans)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
p = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	zenklas1 = ''
	zenklas2 = ''
	if a * x1 + b * y1 + c < 0:
		zenklas1 += '-'
	else:
		zenklas1 += '+'
	if a * x2 + b * y2 + c < 0:
		zenklas2 += '-'
	else:
		zenklas2 += '+'
	if zenklas1 != zenklas2:
		p += 1
print(p)


hm = list(map(int, input().split()))
sc = list(map(int, input().split()))
n = int(input())
cnt = 0
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	if (a * hm[0] + b * hm[1] + c) * (a * sc[0] + b * sc[1] + c) < 0:
		cnt += 1
print(cnt)


import sys
(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)


from collections import namedtuple
import math
Point = namedtuple('Point', ['x', 'y'])
Line = namedtuple('Line', ['a', 'b', 'c'])
toPoint = lambda x: Point(int(x[0]), int(x[1]))
toLine = lambda x: Line(int(x[0]), int(x[1]), int(x[2]))

def cppdiv(a, b):
	if b == 0:
		return a * math.inf
	return a / b

def parallel(l1, l2):
	return cppdiv(l1.a, l1.b) == cppdiv(l2.a, l2.b)

def within(a, p, b):
	return min(a.x, b.x) <= p.x <= max(a.x, b.x) and min(a.y, b.y) <= p.y <= max(a.y, b.y)

def intersect(l1, l2):
	return Point(cppdiv(l1.c * l2.b - l1.b * l2.c, l1.b * l2.a - l1.a * l2.b), cppdiv(l1.a * l2.c - l1.c * l2.a, l1.b * l2.a - l1.a * l2.b))
home = toPoint(input().split())
uni = toPoint(input().split())
n = int(input())
lines = [toLine(input().split()) for _ in range(n)]
home_uni = Line(home.y - uni.y, uni.x - home.x, home.x * uni.y - uni.x * home.y)
c = 0
for l in filter(lambda x: not parallel(home_uni, x), lines):
	if within(home, intersect(home_uni, l), uni):
		c += 1
print(c)


import sys
import time
from sys import stderr
from typing import Union
INF = 10 ** 18 + 3
EPS = 1e-10
MAX_CACHE = 10 ** 9

def print_to_file(function, file=stderr):

	def wrapped(*args, **kwargs):
		res = function(*args, **kwargs)
		print(res, file=file)
		file.flush()
		return res
	return wrapped

def time_it(function, output=stderr):

	def wrapped(*args, **kwargs):
		start = time.time()
		res = function(*args, **kwargs)
		elapsed_time = time.time() - start
		print('"%s" took %f ms' % (function.__name__, elapsed_time * 1000), file=output)
		return res
	return wrapped

class Point(object):

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __le__(self, other):
		return (self.x, self.y) < (other.x, other.y)

	def __lt__(self, other):
		return (self.x, self.y) <= (other.x, other.y)

	def __eq__(self, other):
		return (self.x, self.y) == (other.x, other.y)

class Line(object):

	def __init__(self, *args):
		if len(args) == 2:
			(point1, point2) = args
			self.a = point2.y - point1.y
			self.b = point1.x - point2.x
			self.c = -(point1.x * self.a + point1.y * self.b)
		else:
			(self.a, self.b, self.c) = args

class Segment(Line):

	def __init__(self, point1: Point, point2: Point):
		super().__init__(point1, point2)
		(self.least, self.greatest) = sorted((point1, point2))

	def find_point_of_intersection_with(self, line: Line) -> Union[Point, None]:
		if self.a * line.b == line.a * self.b:
			return None
		res_y = (line.a * self.c - line.c * self.a) / (self.a * line.b - line.a * self.b)
		res_x = (line.b * self.c - line.c * self.b) / (self.b * line.a - line.b * self.a)
		res_point = Point(res_x, res_y)
		if not self.least <= res_point <= self.greatest:
			return None
		return res_point

@time_it
def main():
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	segment = Segment(Point(x1, y1), Point(x2, y2))
	n = int(input())
	res = 0
	for _ in range(n):
		(a, b, c) = map(int, input().split())
		res += segment.find_point_of_intersection_with(Line(a, b, c)) is not None
	print(res)

@print_to_file
def range_of_len(start, length, step=1):
	return range(start, start + length * step, step)

def set_input(file):
	global input
	input = lambda : file.readline().strip()

def set_output(file):
	global print
	local_print = print

	def print(*args, **kwargs):
		kwargs['file'] = kwargs.get('file', file)
		return local_print(*args, **kwargs)
set_input(open('input.txt', 'r') if 'MINE' in sys.argv else sys.stdin)
main()


(x, y) = map(int, input().split())
(p, q) = map(int, input().split())
n = int(input())
k = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	if (a * x + b * y + c) * (a * p + b * q + c) < 0:
		k += 1
print(k)


def ccw(A, B, C):
	return (C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0])

def intersect(A, B, C, D):
	return ccw(A, C, D) != ccw(B, C, D) and ccw(A, B, C) != ccw(A, B, D)

def main(home, uni, n, l):
	ans = 0
	x0 = min(home[0], uni[0]) - 1
	x1 = max(home[0], uni[0]) + 1
	y0 = min(home[1], uni[1]) - 1
	y1 = max(home[1], uni[1]) + 1
	for (i, abc) in enumerate(l):
		(a, b, c) = abc
		if b != 0:
			A = [x0, -(a * x0 + c) / b]
			B = [x1, -(a * x1 + c) / b]
		else:
			A = [-c / a, y0]
			B = [-c / a, y1]
		if intersect(A, B, home, uni):
			ans += 1
	print(ans)

def main_input():
	home = list(map(int, input().split()))
	uni = list(map(int, input().split()))
	n = int(input())
	l = [list(map(int, input().split())) for i in range(n)]
	main(home, uni, n, l)
main_input()


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


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


ct = 0
(x1, y1) = map(int, input().split(' '))
(x2, y2) = map(int, input().split(' '))
for i in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	if b == 0:
		if x1 < -c / a < x2 or x2 < -c / a < x1:
			ct += 1
	else:
		b1 = y1 > (-a * x1 - c) / b
		b2 = y2 > (-a * x2 - c) / b
		if b1 != b2:
			ct += 1
print(ct)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def position(x, y):
	status = line[0] * x + line[1] * y + line[2]
	return status > 0
(Sx, Sy) = value()
(Dx, Dy) = value()
steps = 0
for i in range(Int()):
	line = value()
	steps += position(Sx, Sy) != position(Dx, Dy)
print(steps)


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()


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
r = []
for i in range(n):
	r.append([int(x) for x in input().split()])

def f(a, b, c, x, y):
	if b * y > -c - a * x:
		return 'UP'
	else:
		return 'DOWN'
s = n
for i in range(n):
	if f(r[i][0], r[i][1], r[i][2], x1, y1) == f(r[i][0], r[i][1], r[i][2], x2, y2):
		s -= 1
print(s)


(xhome, yhome) = [int(x) for x in input().split()]
(xuni, yuni) = [int(x) for x in input().split()]
n_roads = int(input())
n_steps = 0
for i in range(n_roads):
	(a, b, c) = [int(x) for x in input().split()]
	hline = a * xhome + b * yhome + c
	uline = a * xuni + b * yuni + c
	if hline * uline < 0:
		n_steps += 1
print(n_steps)


(x1, y1) = [int(_) for _ in input().split()]
(x2, y2) = [int(_) for _ in input().split()]
n = int(input())
ans = 0
for i in range(n):
	(a, b, c) = [int(_) for _ in input().split()]
	zy1 = a * x1 + b * y1 + c
	zy2 = a * x2 + b * y2 + c
	if zy1 > 0 and zy2 < 0 or (zy1 < 0 and zy2 > 0):
		ans += 1
print(ans)


read = lambda : map(int, input().split())
dist = lambda P, a, b, c: a * P[0] + b * P[1] + c
(P1, P2) = (tuple(read()), tuple(read()))
n = int(input())
ans = 0
for i in range(n):
	(a, b, c) = read()
	d1 = dist(P1, a, b, c)
	d2 = dist(P2, a, b, c)
	ans += d1 * d2 < 0
print(ans)


def crazy(n, m, func):
	func = func.strip().split()
	abc = []
	func = [int(func[i]) for i in range(len(func))]
	for i in range(0, len(func), 3):
		abc.append([func[i], func[i + 1], func[i + 2]])
	pict = points(n, m)
	count = 0
	for j in range(len(abc)):
		if intersects_inside(abc[j], pict, n, m):
			count += 1
	return count

def intersects_inside(abc, pict, n, m):
	if abc[0] * pict[1] - pict[0] * abc[1] == 0:
		return False
	y = (abc[2] * pict[0] - abc[0] * pict[2]) / (abc[0] * pict[1] - pict[0] * abc[1])
	if pict[0] == 0:
		x = -(abc[1] * y + abc[2]) / abc[0]
	else:
		x = -(pict[1] * y + pict[2]) / pict[0]
	if x <= max([n[0], m[0]]) and x >= min([n[0], m[0]]) and (y >= min([n[1], m[1]])) and (y <= max([n[1], m[1]])):
		return True
	return False

def points(n, m):
	pict = [None, None, None]
	if n[0] == m[0]:
		pict[0] = 1
		pict[1] = 0
		pict[2] = -n[0]
	else:
		pict[0] = (n[1] - m[1]) / (m[0] - n[0])
		pict[1] = 1
		pict[2] = -(pict[0] * n[0] + pict[1] * n[1])
	return pict
n = input().strip().split()
m = input().strip().split()
n = [int(n[i]) for i in range(len(n))]
m = [int(m[i]) for i in range(len(m))]
f = ''
for i in range(int(input().strip())):
	f += input().strip() + ' '
print(crazy(n, m, f))


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
d = [[int(i) for i in input().split()] for j in range(n)]
count = 0
if x1 != x2:
	k = (y2 - y1) / (x2 - x1)
	b = (y1 * x2 - y2 * x1) / (x2 - x1)
	for i in range(n):
		if -1 * d[i][0] != d[i][1] * k:
			x3 = -1 * (d[i][1] * b + d[i][2]) / (d[i][0] + d[i][1] * k)
			y3 = k * x3 + b
			if max(x1, x2) >= x3 >= min(x1, x2) and max(y1, y2) >= y3 >= min(y1, y2):
				count += 1
else:
	a = 1
	b = 0
	c = -1 * x1
	for i in range(n):
		if d[i][1] != 0:
			x3 = x1
			y3 = -1 * (d[i][2] + d[i][0] * x1) / d[i][1]
			if max(x1, x2) >= x3 >= min(x1, x2) and max(y1, y2) >= y3 >= min(y1, y2):
				count += 1
print(count)


(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)


def main():
	(Hx, Hy) = [int(i) for i in input().split()]
	(Ux, Uy) = [int(i) for i in input().split()]
	N = int(input())
	qtd = 0
	for n in range(N):
		(a, b, c) = [int(i) for i in input().split()]
		if (a * Hx + b * Hy + c) * (a * Ux + b * Uy + c) < 0:
			qtd += 1
	print(qtd)
main()


k1 = list(map(int, input().split()))
(x1, y1) = (k1[0], k1[1])
k2 = list(map(int, input().split()))
(x2, y2) = (k2[0], k2[1])
t = int(input())
d = 0
for i in range(t):
	k3 = list(map(int, input().split()))
	(a, b, c) = (k3[0], k3[1], k3[2])
	k = (a * x1 + b * y1 + c) / (a * x2 + b * y2 + c)
	if k < 0:
		d += 1
print(d)


(a, b) = (int(x) for x in input().split())
(ab, ba) = (int(x) for x in input().split())
n = int(input())

def fun(x1, y1, x2, y2, line):
	var = Line()
	var.build_by_dots(x1, y1, x2, y2)
	under_under = var.a * line.b - line.a * var.b
	if abs(under_under) > 1e-08:
		x = -(var.c * line.b - var.b * line.c) / under_under
		y = -(var.a * line.c - line.a * var.c) / under_under
		if x >= min(x1, x2) and x <= max(x1, x2) and (y >= min(y1, y2)) and (y <= max(y1, y2)):
			return True
	return False

class Line:

	def build_by_dots(l, x1, y1, x2, y2):
		l.a = y1 - y2
		l.b = x2 - x1
		l.c = -l.a * x1 - l.b * y1

	def fun3(l, a, b, c):
		l.a = a
		l.b = b
		l.c = c
res = 0
for i in range(n):
	line = Line()
	line.fun3(*tuple((int(x) for x in input().split())))
	if fun(a, b, ab, ba, line):
		res += 1
print(res)


(h1, h2) = input().split()
(u1, u2) = input().split()
(h1, h2) = (int(h1), int(h2))
(u1, u2) = (int(u1), int(u2))
n = int(input())
lis = []
for i in range(n):
	lis.append(input().split())
for i in range(n):
	for j in range(3):
		lis[i][j] = int(lis[i][j])

def status(a, b, lis):
	if a * lis[0] + b * lis[1] + lis[2] > 0:
		return 1
	else:
		return 0
c = 0
for i in range(n):
	if status(h1, h2, lis[i]) != status(u1, u2, lis[i]):
		c += 1
print(c)


def input_split(f):
	return 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()


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]])))


import math
EPS = 1e-10

def point_in_angle(a, o, b, p):
	op = do_vector(p, o)
	oa = do_vector(a, o)
	ob = do_vector(b, o)
	bo = do_vector(o, b)
	bp = do_vector(p, b)
	ba = do_vector(a, b)
	ao = do_vector(o, a)
	ap = do_vector(p, a)
	ab = do_vector(b, a)
	if (op ^ oa) * (op ^ ob) <= 0 and (bp ^ bo) * (ba ^ bo) >= 0 and ((ap ^ ao) * (ab ^ ao) >= 0):
		return True
	else:
		return False

def check_common_segments(A, B, C, D):
	line1 = line_with_to_points(A, B)
	line2 = line_with_to_points(C, D)
	if function_line(C, line1) * function_line(D, line1) < EPS and function_line(A, line2) * function_line(B, line2) < EPS:
		return 'YES'
	elif abs(function_line(C, line1)) <= EPS and abs(C.length(A) + C.length(B) - A.length(B)) <= EPS:
		return 'YES'
	elif abs(function_line(D, line1)) <= EPS and abs(D.length(A) + D.length(B) - A.length(B)) <= EPS:
		return 'YES'
	elif abs(function_line(A, line2)) <= EPS and abs(A.length(C) + A.length(D) - C.length(D)) <= EPS:
		return 'YES'
	elif abs(function_line(B, line1)) <= EPS and abs(B.length(C) + B.length(D) - C.length(D)) <= EPS:
		return 'YES'
	else:
		return 'NO'

def length_to_ray(point1, point2, point3):
	(x, y) = (point1.x, point1.y)
	(x1, y1) = (point2.x, point2.y)
	(x2, y2) = (point3.x, point3.y)
	if do_vector(point(x, y), point(x1, y1)) * do_vector(point(x2, y2), point(x1, y1)) >= 0:
		return high(do_vector(point(x1, y1), point(x, y)), do_vector(point(x2, y2), point(x, y)), point(x2, y2).length(point(x1, y1)))
	else:
		return min(point(x, y).length(point(x1, y1)), point(x, y).length(point(x2, y2)))

def point_on_circle(circle1, point1):
	if abs((point1.x - circle1.x) ** 2 + (point1.y - circle1.y) ** 2 - circle1.radius ** 2) < EPS:
		return True
	return False

def check(point1, point2):
	if abs(point1.x - point2.x) < EPS and abs(point1.y - point2.y) < EPS:
		return True
	return False

def function_line(point1, line1):
	return line1.a * point1.x + line1.b * point1.y + line1.c

def normal_vector(line, point):
	return vector(line.a, line.b).multiply(-2 * function_line(point, line) / (line.a ** 2 + line.b ** 2))

def normalize(vec):
	x = vec.x / vec.length()
	y = vec.y / vec.length()
	return vector(x, y)

def line_with_to_points(point1, point2):
	a = point2.y - point1.y
	b = point1.x - point2.x
	c = -(a * point1.x + b * point1.y)
	return line(a, b, c)

def common_point(line1, line2):
	if line1.b == 0:
		(line1, line2) = (line2, line1)
	if line1.b != 0 and line1.b * line2.a - line2.b * line1.a != 0:
		x = (line2.b * line1.c - line1.b * line2.c) / (line1.b * line2.a - line2.b * line1.a)
		y = (-line1.c - line1.a * x) / line1.b
		return point(x, y)
	else:
		return point(-1e+18 - 7, -1e+18 - 9)

def from_radian_to_degrees(angle):
	return angle * 180 / math.pi

def point_with_fixed_ratio(point1, point2, a, b):
	x = (point2.x - point1.x) * a / (a + b) + point1.x
	y = point2.y + (point1.y - point2.y) * b / (a + b)
	return point(x, y)

def high(vector1, vector2, length):
	return abs((vector1 ^ vector2) / length)

def do_vector(point1, point2):
	return vector(point1.x - point2.x, point1.y - point2.y)

def s_triangle(first, second, angle):
	return first * second * math.sin(angle) / 2

def s_sector(angle, radius):
	return angle / (2 * math.pi) * math.pi * radius ** 2

class point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def length(self, other):
		return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5

	def __eq__(self, other):
		if self.x == other.x and self.y == other.y:
			return True
		return False

class vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def turn(self, sina, cosa):
		x = self.x * cosa + self.y * sina
		y = -self.x * sina + self.y * cosa
		return vector(x, y)

	def multiply(self, number):
		return vector(self.x * number, self.y * number)

	def __mul__(self, other):
		return self.x * other.x + self.y * other.y

	def __xor__(self, other):
		return self.x * other.y - other.x * self.y

	def polar_angle(self):
		return math.atan2(self.y, self.x)

	def angle(self, other):
		return math.atan2(self ^ other, self * other)

	def length(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

	def __add__(self, other):
		return vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return vector(self.x - other.x, self.y - other.y)

class circle:

	def __init__(self, x, y, radius):
		self.x = x
		self.y = y
		self.radius = radius

	def __eq__(self, other):
		if self.x == other.x and self.y == other.y and (self.radius == other.radius):
			return True
		return False

class line:

	def __init__(self, a, b, c):
		self.a = a
		self.b = b
		self.c = c

	def __eq__(self, other):
		if self.x == other.x and self.y == other.y:
			return True
		return False
(x1, y1) = map(int, input().split())
A = point(x1, y1)
(x2, y2) = map(int, input().split())
B = point(x2, y2)
cnt = 0
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	line1 = line(a, b, c)
	if function_line(A, line1) * function_line(B, line1) < 0:
		cnt += 1
print(cnt)


(xh, yh) = list(map(int, input().split()))
(xu, yu) = list(map(int, input().split()))
n = int(input())
res = 0
for x in range(n):
	(a, b, c) = list(map(int, input().split()))
	if (a * xh + b * yh + c) * (a * xu + b * yu + c) < 0:
		res += 1
print(res)


p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
n = int(input())
lines = [tuple(map(int, input().split())) for _ in range(n)]

def cal(a, b, c, p, q):
	ux = -b
	uy = a
	if b == 0:
		y = 0
		x = -c / a
	else:
		x = 0
		y = -c / b
	(px, py) = p
	(qx, qy) = q
	s1 = (px - x) * uy - (py - y) * ux
	s2 = (qx - x) * uy - (qy - y) * ux
	return 1 if s1 * s2 < 0 else 0
res = 0
for L in lines:
	res += cal(*L, p, q)
print(res)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
cost = 0
for i in range(n):
	(a, b, c) = 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) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
l = []
count = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	if a * x1 + b * y1 + c > 0 and a * x2 + b * y2 + c < 0 or (a * x1 + b * y1 + c < 0 and a * x2 + b * y2 + c > 0):
		count += 1
print(count)


h = list(map(int, input().split()))
u = list(map(int, input().split()))
n = int(input())
t = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	if (a * h[0] + b * h[1] + c) * (a * u[0] + b * u[1] + c) < 0:
		t += 1
print(t)


def s(xx1, yy1, xx2, yy2, x1, y1):
	return (xx1 - x1) * (yy2 - y1) - (yy1 - y1) * (xx2 - x1)
(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
n = int(input())
l = [0] * n
for i in range(n):
	l[i] = tuple(map(int, input().split()))
res = 0
for i in range(n):
	(a, b, c) = l[i]
	xx1 = 0
	xx2 = 1000
	(yy1, yy2) = (0, 0)
	if b == 0:
		yy1 = 0
		yy2 = 1000
		xx1 = -c / a
		xx2 = -c / a
	else:
		yy1 = (-a * xx1 - c) / b
		yy2 = (-a * xx2 - c) / b
	if s(xx1, yy1, xx2, yy2, x1, y1) * s(xx1, yy1, xx2, yy2, x2, y2) < 0:
		res += 1
print(res)


(h1, h2) = list(map(int, input().split()))
(u1, u2) = list(map(int, input().split()))
pasos = 0
for i in int(input()) * '_':
	(a, b, c) = list(map(int, input().split()))
	if (a * h1 + b * h2 + c) * (a * u1 + b * u2 + c) < 0:
		pasos += 1
print(pasos)


(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()]
	p = a * x1 + b * y1 + c < 0
	q = a * x2 + b * y2 + c < 0
	if p ^ q == True:
		ans += 1
print(ans)


(x1, y1) = [int(i) for i in input().split()]
(x2, y2) = [int(i) for i in input().split()]
n = int(input())
m = 0
for i in range(n):
	(x, y, c) = [int(g) for g in input().split()]
	if x1 * x + y1 * y + c > 0:
		l = 1
	else:
		l = -1
	if l == -1 and x2 * x + y2 * y + c > 0:
		m += 1
	elif l == 1 and x2 * x + y2 * y + c < 0:
		m += 1
print(m)


import math
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def line(l, p):
	d = l[0] * p[0] + l[1] * p[1] + l[2]
	if d > 0:
		return 1
	elif d < 0:
		return -1
	return 0

def intersection(L1, L2):
	D = L1[0] * L2[1] - L1[1] * L2[0]
	Dx = L1[2] * L2[1] - L1[1] * L2[2]
	Dy = L1[0] * L2[2] - L1[2] * L2[0]
	if D != 0:
		x = Dx / D
		y = Dy / D
		return [x, y]
	else:
		return False
s = L()
e = L()
n = I()
lines = []
for i in range(n):
	l = L()
	lines.append(l)
p1 = [s[0], e[1]]
p2 = [e[0], s[1]]
c1 = 0
c2 = 0
c3 = 0
c4 = 0
c5 = 0
for i in range(n):
	if line(lines[i], p1) * line(lines[i], s) <= 0:
		c1 += 1
	if line(lines[i], p2) * line(lines[i], s) <= 0:
		c2 += 1
	if line(lines[i], p1) * line(lines[i], e) <= 0:
		c3 += 1
	if line(lines[i], p2) * line(lines[i], e) <= 0:
		c4 += 1
	if line(lines[i], s) * line(lines[i], e) <= 0:
		c5 += 1
print(min(c1 + c3, c2 + c4, c5))


def town():
	(x1, y1) = [int(i) for i in input().split()]
	(x2, y2) = [int(i) for i in input().split()]
	n = int(input())
	ans = 0
	for i in range(n):
		(a, b, c) = [int(k) for k in input().split()]
		if a * x1 + b * y1 + c < 0 and a * x2 + b * y2 + c > 0 or (a * x1 + b * y1 + c > 0 and a * x2 + b * y2 + c < 0):
			ans += 1
	print(ans)
	return
town()


def list_to_int(l):
	return [int(x) for x in l]

def f_value(point, params):
	return point[0] * params[0] + point[1] * params[1] + params[2] > 0

def is_separator(home, uni, params):
	return f_value(home, params) ^ f_value(uni, params)
home = list_to_int(input().split(' '))
uni = list_to_int(input().split(' '))
n = int(input())
distance = 0
for i in range(n):
	params = list_to_int(input().split(' '))
	if is_separator(home, uni, params):
		distance += 1
print(distance)


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


def main():
	(x1, y1) = map(float, input().split())
	(x2, y2) = map(float, input().split())
	n = int(input())
	res = 0
	for _ in range(n):
		(a, b, c) = map(float, input().split())
		if a and b:
			(x3, y3, x4, y4) = (0.0, -c / b, 1.0, -a / b)
		elif a:
			(x3, y4) = (-c / a, 1.0)
			y3 = x4 = 0.0
		else:
			x3 = y4 = 0.0
			(y3, x4) = (-c / b, 1.0)
		ax = x1 - x3
		ay = y1 - y3
		bx = x2 - x3
		by = y2 - y3
		a = ax * y4 - ay * x4
		b = bx * y4 - by * x4
		if a < 0 < b or b < 0 < a:
			res += 1
	print(res)
main()


s = tuple(map(int, input().split()))
e = tuple(map(int, input().split()))
r = 0
n = int(input())
while n != 0:
	n -= 1
	(a, b, c) = map(int, input().split())
	if a == 0 or b == 0:
		if a == 0:
			(p1, p2) = ((0, -c / b), (1, -c / b))
		else:
			(p1, p2) = ((-c / a, 0), (-c / a, 1))
	else:
		(p1, p2) = ((0, -c / b), (-b / a, -c / b + 1))
	v1 = (s[0] - p1[0]) * (p2[1] - p1[1]) - (s[1] - p1[1]) * (p2[0] - p1[0])
	v2 = (e[0] - p1[0]) * (p2[1] - p1[1]) - (e[1] - p1[1]) * (p2[0] - p1[0])
	if v1 > 0 > v2 or v1 < 0 < v2:
		r += 1
print(r)


lectura = lambda : map(int, input().split())
(xCasa, yCasa) = lectura()
(xObj, yObj) = lectura()
numeroCalles = int(input())
conclusion = 0
for i in range(numeroCalles):
	(a, b, c) = lectura()
	linea1 = a * xCasa + b * yCasa + c
	linea2 = a * xObj + b * yObj + c
	if linea1 * linea2 < 0:
		conclusion += 1
print(conclusion)


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
count = 0
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	f = lambda x, y: a * x + b * y + c
	if f(x1, y1) * f(x2, y2) < 0:
		count += 1
print(count)


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


(x1, y1) = map(int, input().split())
(x2, y2) = map(int, input().split())
a1 = y1 - y2
b1 = x2 - x1
c1 = x2 * (y2 - y1) - y2 * (x2 - x1)

def intersect(a2, b2, c2):
	global a1, b1, c1, x1, y1, x2, y2
	if a1 * b2 == a2 * b1:
		return False
	x = (b1 * c2 - b2 * c1) / (a1 * b2 - b1 * a2)
	y = (a1 * c2 - c1 * a2) / (b1 * a2 - a1 * b2)
	if min(x1, x2) <= x <= max(x1, x2) and min(y1, y2) <= y <= max(y1, y2):
		return True
	return False
m = int(input())
ans = 0
for i in range(m):
	(a2, b2, c2) = map(int, input().split())
	if intersect(a2, b2, c2):
		ans += 1
print(ans)


(px, py) = map(int, input().split())
(qx, qy) = map(int, input().split())
(n, s) = (int(input()), 0)
for _ in range(n):
	(a, b, c) = map(int, input().split())
	if not a:
		(x, y) = (0, -c / b)
	else:
		(x, y) = (-c / a, 0)
	s += ((px - x) * a + (py - y) * b) * ((qx - x) * a + (qy - y) * b) < 0
print(s)


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 = 1000000000.0 + 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)


def sign(x):
	return (x >= 0) * 2 - 1
(x1, y1) = list(map(int, input().split(' ')))
(x2, y2) = list(map(int, input().split(' ')))
n = int(input())
count = 0
for _ in range(n):
	(a, b, c) = list(map(int, input().split(' ')))
	if sign(a * x1 + b * y1 + c) * sign(a * x2 + b * y2 + c) == -1:
		count += 1
print(count)


EPS = 1e-08
(xx1, yy1) = (int(x) for x in input().split())
(xx2, yy2) = (int(x) for x in input().split())
n = int(input())

def intersect_between_dots(x1, y1, x2, y2, line):
	liline = Line()
	liline.build_by_dots(x1, y1, x2, y2)
	under_under = liline.a * line.b - line.a * liline.b
	if abs(under_under) > EPS:
		x = -(liline.c * line.b - liline.b * line.c) / under_under
		y = -(liline.a * line.c - line.a * liline.c) / under_under
		if x >= min(x1, x2) and x <= max(x1, x2) and (y >= min(y1, y2)) and (y <= max(y1, y2)):
			return True
	return False

class Line:

	def build_by_dots(self, x1, y1, x2, y2):
		self.a = y1 - y2
		self.b = x2 - x1
		self.c = -self.a * x1 - self.b * y1

	def build_by_abc(self, a, b, c):
		self.a = a
		self.b = b
		self.c = c
res = 0
for i in range(n):
	line = Line()
	line.build_by_abc(*tuple((int(x) for x in input().split())))
	if intersect_between_dots(xx1, yy1, xx2, yy2, line):
		res += 1
print(res)


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


(x, y) = map(int, input().split())
(x1, y1) = map(int, input().split())
n = int(input())
steps = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	p = a * x + b * y + c
	q = a * x1 + b * y1 + c
	if p * q < 0:
		steps += 1
print(steps)