#00010B

IT2

I and Ti 2: The Return of I and Ti


Congratulations, you have proven yourselves to be good programmers when you were helping I and Ti to find out whether they would have enough fuel for their intergalactic trip, during the first round of these qualifications. However, as all of the stubborn aliens, they were not listening to you, and as a consequence of that, they, as expected, ran out of fuel. They are in a really unenviable situation now. Without fuel, they levitate in airless space, while an asteroid shower is falling on them! This time they are begging you to help them find out how many asteroids will hit their ship (that is, whether it will be capable of withstanding the concussions), and promising that they will listen to you this time, swearing on their daily bread.


InputFrom the first line of the standard input read four real numbers p0, q0, r0 and s0 that represent the starting and the ending coordinates of I's and Ti's ship in the fixed plane (assume that the ship is of infinitely small width and height). The next line will contain an integer n (1 <= n <= 750 000), that represent the number of falling asteroids. Each of the next n lines will contain four real numbers pi, qi, ri and si, that represent the first and the second piercing point of ith asteroid through the fixed plane (assume that the asteroids are also of infinitely small width and height).

OutputTo the first line of the standard output write one integer that represent the number of asteroids that will hit I's and Ti's ship.

Input:0.0 0.0 3.0 3.0
5
1.0 -1.0 -1.0 1.0
1.0 1.0 2.0 2.0
1.0 1.0 5.0 5.0
3.0 3.0 11.7 6.3
-1.0 0.0 2.0 3.0

Output:
4
Explanation:
All the asteroids but the last one will hit the ship.

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.