atcoder#ABC250A. [ABC250A] Adjacent Squares

[ABC250A] Adjacent Squares

Score : 100100 points

Problem Statement

There is a grid with HH horizontal rows and WW vertical columns. Let (i,j)(i,j) denote the square at the ii-th row from the top and the jj-th column from the left. Find the number of squares that share a side with Square (R,C)(R, C).

Here, two squares (a,b)(a,b) and (c,d)(c,d) are said to share a side if and only if ac+bd=1|a-c|+|b-d|=1 (where x|x| denotes the absolute value of xx).

Constraints

  • All values in input are integers.
  • 1RH101 \le R \le H \le 10
  • 1CW101 \le C \le W \le 10

Input

Input is given from Standard Input in the following format:

HH WW

RR CC

Output

Print the answer as an integer.

3 4
2 2
4

We will describe Sample Inputs/Outputs 1,21,2, and 33 at once below Sample Output 33.

3 4
1 3
3
3 4
3 4
2

When H=3H=3 and W=4W=4, the grid looks as follows.

  • For Sample Input 11, there are 44 squares adjacent to Square (2,2)(2,2).
  • For Sample Input 22, there are 33 squares adjacent to Square (1,3)(1,3).
  • For Sample Input 33, there are 22 squares adjacent to Square (3,4)(3,4).

1 10
1 5
2
8 1
8 1
1
1 1
1 1
0