#K42907. Minimum Steps to Cover All Cells in a Grid

    ID: 27191 Type: Default 1000ms 256MiB

Minimum Steps to Cover All Cells in a Grid

Minimum Steps to Cover All Cells in a Grid

You are given an M x N grid and a starting coordinate (sx, sy). The task is to determine the minimum number of steps required to visit every cell in the grid at least once. You may move one cell at a time in any of the four directions: up, down, left, and right.

Note: The starting cell is considered visited at the start, so it does not count as a step. The minimum number of steps required is simply equal to the total number of cells minus one.

The formula to compute the answer is given by:

$$ steps = M \times N - 1 $$

Example: For a 3x3 grid starting at (0, 0), the minimum steps would be 9 - 1 = 8.

inputFormat

The input consists of a single line containing four space-separated integers: M (the number of rows), N (the number of columns), sx (the starting row index), and sy (the starting column index).

outputFormat

Output a single integer representing the minimum number of steps required to cover all the cells in the grid.

## sample
3 3 0 0
8