#K15551. Taco: Minimum Moves to Reach the Last Row
Taco: Minimum Moves to Reach the Last Row
Taco: Minimum Moves to Reach the Last Row
Emma is trapped in a grid consisting of N rows and M columns. She starts at the first row and aims to reach any cell in the last row. In one move, Emma can move from her current cell to a cell in the next row while changing her column by at most one (i.e. moving to an adjacent column). Surprisingly, it turns out that the minimum number of moves required to guarantee reaching the last row is always given by the formula , regardless of the number of rows .
For example, if the grid has 3 rows and 5 columns, then the answer is . Your task is to calculate this minimum number of moves for given values of N and M.
inputFormat
The input consists of a single line containing two space-separated integers N and M, where N (≥ 1) is the number of rows and M (≥ 1) is the number of columns in the grid.
outputFormat
Output a single integer representing the minimum number of moves Emma needs to reach any cell in the last row, which is computed as .## sample
3 5
4