Sum of neighbors#11670

Sum of neighbors

1 second
128 megabytes
Medium

In a square area of size n \times n, the cells are numbered consecutively from to n^2 - 1, from top to bottom and from left to right in each row.

Nyasyr stands in the cell numbered in this area and wants to find the sum of the numbers of all neighboring cells. Help Nyasyr with this task.

Note that each cell can have no more than neighbors directly above, below, to the left, and to the right.

Below is an example with n = 4 and k = 11.

Here Nyasyr stands on the cell with number , and neighboring cells are marked with circles. In this case, there is no neighbor on the right.

Input

Two integers (1 \le n \le 10^6) and (0 \le k < n^2).

Output

Print the sum of the numbers of all neighboring cells of the given cell.

Examples

Example 2

Loading
Loading

Example 1

Loading
Loading