#abc250a. [abc250_a]Adjacent Squares
[abc250_a]Adjacent Squares
Problem Statement
There is a grid with horizontal rows and vertical columns. Let denote the square at the -th row from the top and the -th column from the left.
Find the number of squares that share a side with Square .
Here, two squares and are said to share a side if and only if (where denotes the absolute value of ).
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3 4
2 2
Sample Output 1
4
We will describe Sample Inputs/Outputs , and at once below Sample Output .
Sample Input 2
3 4
1 3
Sample Output 2
3
Sample Input 3
3 4
3 4
Sample Output 3
2
When and , the grid looks as follows.
- For Sample Input , there are squares adjacent to Square .
- For Sample Input , there are squares adjacent to Square .
- For Sample Input , there are squares adjacent to Square .
Sample Input 4
1 10
1 5
Sample Output 4
2
Sample Input 5
8 1
8 1
Sample Output 5
1
Sample Input 6
1 1
1 1
Sample Output 6
0