Making a map is not simple. Because the Earth is round, moving it onto a two dimensional plane introduces distortion, and a high resolution map is far too large to fit on a single sheet of paper. So the map is split into several pieces, printed on several sheets, and joined together.
We want to print a map using as few sheets as possible. Every sheet has the same size.
The same map can need a different number of sheets depending on how the sheets are placed. For example, one placement might print the map on 14 sheets, while a better placement needs only 10. Both placements use sheets of the same size and orientation.
Given the map, find the minimum number of sheets needed to print it. The map is a single closed polygon whose edges do not cross.
Every sheet is an axis aligned rectangle and cannot be rotated. Neighboring sheets meet corner to corner, forming one aligned grid, and you may translate the whole grid to any position you like. All input coordinates are integers, but the sheets may be placed at non integer positions.
If the map only touches the boundary line of a sheet, that sheet is not counted. In other words, a sheet is needed only when the area shared by its interior and the map interior is greater than 0. To absorb floating point error, the map poking outside a sheet by at most 10−6 is ignored.
The first line contains the number of map vertices n (3≤n≤50) and the sheet size xs, ys (1≤xs,ys≤100).
Each of the next n lines contains the coordinates x and y of a map vertex (0≤x≤10xs, 0≤y≤10ys). The vertices are given in clockwise or counterclockwise order.
Print, on a single line, the minimum number of sheets needed to print the map.