favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

# Queen Move

The queen stands on the chessboard of size m × n. How many squares does the queen attack?

#### Input

Four positive integers: the size of the chessboard m and n and the queen's coordinates x and y (1xm109, 1yn109).

#### Output

Print the number of squares the queen attacks.

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
8 8
4 5
Output example #1
27

Input example #2
1000000000 3
999999999 2
Output example #2
1000000005