atcoder#ABC250A. [ABC250A] Adjacent Squares
[ABC250A] Adjacent Squares
Score : points
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.
3 4
2 2
4
We will describe Sample Inputs/Outputs , and at once below Sample Output .
3 4
1 3
3
3 4
3 4
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 .
1 10
1 5
2
8 1
8 1
1
1 1
1 1
0