Independent House

Time limit: 0.05s Memory limit: 32MB Input: Output:

William is exhausted of its annoying roommates and their never-ending parties. But after some months of money saving, he has finally accomplished to move into an independent house!

Since his budget is quite limited, he opted for a prefabricated building consisting of two blocks:

  • a ground block, with the entrance and a living space, of size A×BA \times B centimeters;
  • a roof block with a bedroom, to be put on top of the other.

The roof block is usually supposed to have the same size of the ground block. However, William has been cheated by an unprofessional ebay vendor which shipped a roof block of size X×YX \times Y centimeters to him. Now William has no choice but to make the best out of a bad situation, and use the provided blocks in some way. In particular, due to their peculiar joints[1]^{[1]} the blocks need to be arranged so that:

  • the roof block is above the ground block;
  • the roof block has a compatible orientation with the ground block, that is, you can rotate it only by multiples of 90 degrees with respect to the other;
  • they are translated only by an integer amount of centimeters.

William is worried about the robustness of the building, which could be impaired because part of the roof block’s floor could not lay on the ground block. In particular, for a certain disposition of the blocks, the risk can be calculated in this way:

  • consider the region of the floor of the roof block not laying on the ground block;
  • this region might consist of one or more connected parts: then, consider the largest one;
  • the area of this connected part equals to the risk associated to this particular disposition.

Task

Find the disposition giving the minimum risk!

Input data

The first and only line contains four integers AA, BB, XX, YY.

Output data

You need to write a single line with an integer: the minimum risk attainable with the given blocks.

Constraints and clarifications

  • 1A,B,X,Y10 0001 \leq A, B, X, Y \leq 10 \ 000
  • [1]^{[1]}The joints are put at any point with integer coordinates (in centimeters) within the connecting face.
# Points Constraints
1 5 Examples.
2 25 A=BA = B, X=YX = Y
3 30 A=BA = B
4 40 No additional constraints.

Example 1

stdin

10 20 20 8

stdout

0

Explanation

We avoid any risk with the following configuration:

Example 2

stdin

10 10 20 8 

stdout

40

Explanation

We minimize the risk with the following configuration, where both risky regions (in blue) have area 4040:

Example 2

stdin

12 14 18 15

stdout

102

Explanation

A possible configuration minimizing the risk is the following, where the single risky region is highlighted in blue:

Log in or sign up to be able to send submissions!