Time limit
2s
Memory limit
128 MB
A single polygon-shaped sheet of colored paper lies on the plane. It is cut by one straight line parallel to the x-axis or the y-axis. Determine how many pieces the sheet is divided into.
The first line contains the coordinates of two points (x1, y1) and (x2, y2) that lie on the cutting line. The line is parallel to the x-axis or the y-axis.
The second line contains N, the number of vertices of the polygon representing the paper. Each of the next N lines contains one vertex coordinate (x, y).
All coordinates are integers separated by spaces and are between 0 and 1,000,000, inclusive. The vertices are given in counterclockwise order, and N is an integer between 3 and 100,000, inclusive. The input is valid, so no error checking is required. Every polygon formed after the cut has at least three vertices.
Print the number of pieces produced after cutting the paper.
There is no additional hint.