Skip to main content
LIVE CONTEST: Round #7 · Begin Marathon is live now! …
Problems
#849

~/algor $ cat problems/VtYCOOUrT5vT

Breaking a chocolate bar

Easy 1000 ms 64 MB 6%
Share

A chocolate bar of size consists of squares. One break splits any single piece into two along a straight line between the squares; you cannot stack several pieces and break them at once. What is the smallest number of breaks needed to split the bar completely into squares?

A chocolate bar: n rows and m columns, break lines between the squares

Input

One line contains two positive integers: and .

Output

One integer — the smallest number of breaks.

Note

Examples

Input #1
4 3
Output #1
11
Input #2
1 1
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.