Under construction

Still being built. Things may change

Planets of Two Dimensions

Time limit1sMemory limit1024 MB

Summary
Given n planets in dimension X and m in dimension Y, find the longest trip that visits no planet twice and never visits two same-dimension planets in a row.
Level

Easy2 of 10

Topics
Math
Solved
No attempts yet

Problem

Rick and Morty plan a trip through the planets of two recently discovered dimensions. The dimensions have no names yet, so we call them XX and YY. Dimension XX has nn planets, and dimension YY has mm planets. Rick does not want Morty to plan the adventure, but since Morty's birthday is soon, Rick agrees to give in once. Morty may choose which planets to visit and in what order. He does not want to visit the same planet twice. He also does not want to visit two planets from the same dimension in a row. The trip may start and end on any planet of either dimension. Rick does not explain that these conditions sometimes make it impossible to visit all n+mn + m planets. Find the maximum number of planets that can be visited without breaking Morty's conditions.

Input

The first line contains two integers nn and mm, separated by a space, the number of planets in dimensions XX and YY (1⩽n,m⩽1091 \leqslant n, m \leqslant 10^9).

Output

Print the answer to the problem on a single line.

Examples3

  1. Example 1

    Input
    2 3
    
    Expected output
    5
    
  2. Example 2

    Input
    4 4
    
    Expected output
    8
    
  3. Example 3

    Input
    5 11
    
    Expected output
    11