Mad Tea Party
Near the house, under the tree, stood a table covered with a cloth. At the table, the March Hare and the Hatter were drinking tea, while the Dormouse slept soundly between them. The Hatter and the Hare leaned on her as if she were a pillow and conversed over her head.
"Poor Dormouse," thought Alice. "She must be uncomfortable! Still, she is asleep, so she doesn't mind."
Alice's Adventures in Wonderland (translated by N.M. Demurova)
Whenever the Hatter, the March Hare, and the Dormouse sit down for tea, they circle the table multiple times. The table is set with tea cups arranged in a rectangle of size M*N, numbered from 1 to M*N, with each number appearing exactly once.
The Hatter selects the cups with the highest numbers from each row, pours tea into them, drinks it, and sums the numbers to obtain the total A.
The March Hare selects the cups with the highest numbers from each column, pours tea into them, drinks it, and sums the numbers to obtain the total B.
Afterward, the Dormouse wakes up, adds the numbers A and B, and then falls back asleep. What is the minimum number the Dormouse could have calculated?
Input
The input file contains 2 numbers N and M separated by a space. All numbers in the input file are natural numbers and do not exceed 1000.
Output
In the output file, print the minimum number the Dormouse could have calculated.