#K86702. Longest Path with One Turn

    ID: 36923 Type: Default 1000ms 256MiB

Longest Path with One Turn

Longest Path with One Turn

Given a grid of size m × n, your task is to determine the longest possible path length from the top-left corner (1,1) to the bottom-right corner (m,n) under the constraint that the path contains exactly one turn (i.e. one change in direction). In other words, you are only allowed to switch from moving horizontally to vertically (or vice versa) once.

If the grid has a single row or a single column (i.e. when m=1 or n=1), a turn is not possible and the answer is simply given by $$m+n-1$$. Otherwise, the longest path is computed by the formula: $$\max((m-1)+n,\;m+(n-1))$$. Note that when both dimensions are greater than 1, the formula simplifies to m+n-1 as well.

inputFormat

The input consists of two positive integers m and n separated by a space, representing the number of rows and columns of the grid respectively.

outputFormat

Output a single integer on a line which represents the longest path length as defined. The output should be written to stdout.

## sample
3 4
6