Competitions
Азербайджан - подготовка. Февраль 27
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 (1 ≤ x ≤ m ≤ 109
, 1 ≤ y ≤ n≤ 109
).
Output
Print the number of squares the queen attacks.
Input example #1
8 8 4 5
Output example #1
27
Input example #2
1000000000 3 999999999 2
Output example #2
1000000005