Mary has an $n\times m$ piece of paper that she wants to cut into $1\times1$ pieces according to the following rules:

She can only cut one piece of paper at a time, meaning she cannot fold the paper or layer already-cut pieces on top of one another. 
Each cut is a straight line from one side of the paper to the other side of the paper. For example, the diagram below depicts the three possible ways to cut a $3\times2$ piece of paper: 

Given $n$ and $m$, find and print the minimum number of cuts Mary must make to cut the paper into $n\cdot m$ squares that are $1\times1$ unit in size. 

Input Format

A single line of two space-separated integers denoting the respective values of $n$ and $m$.

Constraints

$1\leq n,m\leq10^9$

Output Format

Print a long integer denoting the minimum number of cuts needed to cut the entire paper into $1\times1$ squares.

Sample Input
3 1

Sample Output
2

Explanation

Mary first cuts the $3\times1$ piece of paper into a $1\times1$ piece and a $2\times1$ piece. She then cuts the $2\times1$ piece into two $1\times1$ pieces:

Because it took her two cuts to get $n\times m=3$ pieces of size $1\times1$, we print $2$ as our answer.

Difficulty: EASY

Solutions:
(n, m) = [int(i) for i in input().strip().split(' ')]
print(n * m - 1)


(a, b) = [int(n) for n in input().split()]
print(a * b - 1)


(N, M) = list(map(int, input().split()))
print(N * M - 1)


import sys
(m, n) = [int(i) for i in input().strip().split()]
print(m - 1 + m * (n - 1))


(n, m) = [int(x) for x in input().split()]
print(n - 1 + (m - 1) * n)


(n, m) = map(int, input().strip().split())
print(n * m - 1)


(n, m) = map(int, input().strip().split())
length = max(n, m)
width = min(n, m)
print(width - 1 + (length - 1) * width)


import sys
(n, m) = input().strip().split()
print(int(n) * int(m) - 1)


(m, n) = map(int, input().split())
print(m * n - 1)


a = [int(i) for i in input().split()]
print(a[0] * a[1] - 1)


nm = input().split()
n = int(nm[0])
m = int(nm[1])
print(n * m - 1)


(n, m) = map(int, input().split())
print(n * m - 1)


(n, m) = list(map(int, input().strip().split()))
print(n * m - 1)


import sys
data = sys.stdin.readlines()
(n, m) = data[0].strip().split()
print(int(n) * int(m) - 1)


(n, m) = list(map(int, input().split()))
a = min(n, m)
b = max(n, m)
print(a - 1 + a * (b - 1))


(m, n) = tuple((int(x) for x in input().strip().split()))
print(n * m - 1)


(n, m) = [int(x) for x in input().split()]
print(n * m - 1)


(n, m) = map(int, input().split())
(n, m) = (max(n, m), min(n, m))
cuts = 0
cuts += m - 1
cuts += m * (n - 1)
print(cuts)


(n, m) = input().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


(n, m) = map(int, input().split(' '))
print(n * m - 1)


from fileinput import input
data = input()
(n, m) = map(int, next(data).split())
if n == 1:
	if m == 1:
		print(0)
	else:
		print(m - 1)
elif m == 1:
	print(n - 1)
else:
	print(n - 1 + n * (m - 1))


(n, m) = list(map(int, input().split()))
print(n * m - 1)


(n, m) = map(int, input().split())
print(n * m - 1)


(n, m) = map(int, input().split())
if n > m:
	(n, m) = (m, n)
print(n - 1 + n * (m - 1))


(N, M) = [int(i) for i in input().split()]
print(M * N - 1)


(n, m) = [int(x) for x in input().split()]
if n == 1:
	print(m - 1)
elif m == 1:
	print(n - 1)
else:
	print(n * m - 1)


(a, b) = map(int, input().split())
print(a * b - 1)


(n, m) = map(int, input().split())
print(n * m - 1)


(n, m) = map(int, input().split())
print(n * m - 1)


(n, m) = input().strip().split()
(n, m) = [int(n), int(m)]
print(m * n - 1)


(n, m) = map(int, input().split())
print(n - 1 + (m - 1) * n)


paper = [int(x) for x in input().strip().split(' ')]
print(paper[0] - 1 + paper[0] * (paper[1] - 1))


(n, m) = list(map(int, input().split()))
if n == 1 or m == 1:
	print(m + n - 2)
else:
	print(m * n - 1)


import sys
t = input().split()
m = int(t[0])
n = int(t[1])
if m > n:
	total = n - 1 + (m - 1) * n
else:
	total = m - 1 + (n - 1) * m
print(total)


(n, m) = [int(x) for x in input().split()]
if n > m:
	(n, m) = (m, n)
cuts = 0
cuts += n - 1
cuts += n * (m - 1)
print(cuts)


(n, m) = [int(x) for x in input().split(' ')]
print(n * m - 1)


(m, n) = [int(elem) for elem in input().split()]
print(m - 1 + (n - 1) * m)


(n, m) = list(map(int, input().strip().split(' ')))
result = n - 1 + n * (m - 1)
print(result)


(n, m) = map(int, input().strip().split())
print(str(n * m - 1))


(m, n) = input().strip().split()
print(int(m) * int(n) - 1)


(n, m) = [int(x) for x in input().split()]
(n, m) = (min(m, n), max(m, n))
if n != 1:
	print(n - 1 + n * (m - 1))
elif m != 1:
	print(m - 1)
else:
	print('0')


(n, m) = input().split()
n = int(n)
m = int(m)
count = 0
s = 0
print(n * m - 1)


(n, m) = map(int, input().split())
print(n - 1 + (m - 1) * n)


[n, m] = [int(i) for i in input().split()]
print(n * m - 1)


(n, m) = map(int, input().split())
print(m * n - 1)


def nCuts(m, n):
	if n > m:
		(m, n) = (n, m)
	return n - 1 + n * (m - 1)
import sys
(m, n) = map(int, sys.stdin.read().strip().split(' '))
print(nCuts(m, n))


(m, n) = [int(s) for s in input().strip().split(' ')]
print(m * n - 1)


(n, m) = [int(x) for x in input().split()]
if n == 1 and m == 1:
	print(0)
elif n == 1:
	print(m - 1)
elif m == 1:
	print(n - 1)
else:
	a = max(n, m) - 1
	b = min(n, m) - 1
	print(a + b * max(n, m))


(N, M) = [int(x) for x in input().split(' ')]
print(M * N - 1)


(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(m * n - 1)


(n, m) = map(int, input().split())
print(n - 1 + n * (m - 1))


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
if n == 1 and m == 1:
	print(0)
	sys.exit(0)
if m > n:
	t = n
	n = m
	m = t
if n == 1:
	n = 2
print((n - 1) * m + (m - 1))


line = input().strip()
list1 = [int(x) for x in line.split()]
n = list1[0]
m = list1[1]
print(m - 1 + m * (n - 1))


(n, m) = list(map(int, input().split()))
mini = min(n, m)
maxi = max(n, m)
count = min(mini - 1 + mini * (maxi - 1), maxi - 1 + maxi * (mini - 1))
print(count)


inp = input().split()
n = int(inp[0])
m = int(inp[1])
print(n * m - 1)


(a, b) = [int(x) for x in input().split()]
print(a - 1 + a * (b - 1))


(a, b) = map(int, input().split(' '))
print(a - 1 + a * (b - 1))


(n, m) = map(int, input().split())
vertical = min(n, m) - 1
print(vertical + min(n, m) * (max(n, m) - 1))


(n, m) = (int(x) for x in input().split())
print(n * m - 1)


(n, m) = map(int, input().split())
p = min(n, m)
q = max(n, m)
q -= 1
print(q * p + (p - 1))


(n, m) = [int(i) for i in input().split()]
if m != 1 and n != 1:
	print(n - 1 + n * (m - 1))
elif n == 1:
	print(m - 1)
else:
	print(n - 1)


(n, m) = input().split(' ')
n = int(n)
m = int(m)
print(n - 1 + n * (m - 1))


(m, n) = input().strip().split()
(m, n) = (int(m), int(n))
result = n - 1 + (m - 1) * n
if n < 1 or m < 1:
	result = 0
print(result)


(n, m) = map(int, input().split())
print(n * m - 1)


(a, b) = map(int, input().split())
print(b - 1 + (a - 1) * b)


(n, m) = input().strip().split(' ')
(n, m) = (int(n), int(m))
print(n - 1 + n * (m - 1))


(n, m) = input().strip().split(' ')
x = int(n) - 1
y = int(n) * (int(m) - 1)
print(x + y)


(n, m) = map(int, input().split())
print(n * m - 1)


(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
res = n * m - 1
if m == 0:
	print(0)
else:
	print(res)


x = list(input().split())
r = int(x[0]) * int(x[1]) - 1
print(r)


(m, n) = [int(x) for x in input().split()]
bigger = max(m, n)
smaller = min(m, n)
if smaller == 1:
	if bigger == 1:
		print(0)
	else:
		print(bigger - 1)
else:
	print(smaller - 1 + smaller * (bigger - 1))


arr = [int(i) for i in input().split(' ')]
(n, m) = (arr[0], arr[1])
print(n * m - 1)


(n, m) = [int(x) for x in input().split()]
print(n - 1 + n * (m - 1))


(m, n) = map(int, input().split())
print(m * n - 1)


(a, b) = map(int, input().strip().split())
if a > 1 and b > 1:
	if a >= b:
		ans = b - 1
		ans = ans + b * (a - 1)
	else:
		ans = a - 1
		ans = ans + a * (b - 1)
	print(ans)
elif a == 1 and b == 1:
	print(0)
elif a == 1:
	ans = b - 1
	print(ans)
elif b == 1:
	ans = a - 1
	print(ans)


(a, b) = [int(c) for c in input().split()]
cuts = b - 1 + b * (a - 1)
print(cuts)


m = list(map(lambda x: int(x), input().split()))
horCuts = m[0] - 1
vertCuts = m[0] * (m[1] - 1)
print(sum([horCuts, vertCuts]))


(n, m) = input().split()
(n, m) = (int(n), int(m))
print(n * m - 1)


(n, m) = list(map(int, input().split()))
hf = n - 1 + n * (m - 1)
vf = m - 1 + m * (n - 1)
res = min(hf, vf)
print(res)


(n, m) = map(int, input().split(' '))
print(n * m - 1)


(n, m) = [int(x) for x in input().strip().split()]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(m * n - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
j = 0
k = 0
if n % 2 != 0 or (n % 2 == 0 and n > 0):
	j = n - 1
if m % 2 != 0 or (m % 2 == 0 and m > 0):
	k = m - 1
print(m * n - 1)


inputs = input()
list = inputs.split()
n = int(list[0])
m = int(list[1])
firstCut = n - 1
if m > 1:
	secCut = m - 1
else:
	secCut = m
firstCut
if m > 1:
	res = n * m - 1
else:
	res = firstCut
print(res)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n - 1 + n * (m - 1))


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
cuts = n * m - 1
print(cuts)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
n = (n - 1) * m
print(n + m - 1)


(n, m) = map(int, input().split())
if n == 1:
	print(m - 1)
elif m == 1:
	print(n - 1)
else:
	area = n * m
	print(area - 1)


(n, m) = map(int, input().split())
if m > 1 and n > 1:
	if m == n:
		print(n - 1 + (m - 1) * n)
	elif m > n:
		print(n - 1 + (m - 1) * n)
	else:
		print(m - 1 + (n - 1) * m)
elif m == 1:
	print(n - 1)
elif n == 1:
	print(m - 1)
else:
	print(0)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
ans = (n - 1) * m + (m - 1)
print(ans)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
q = m - 1 + m * (n - 1)
print(q)


(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
print(n - 1 + n * (m - 1))


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
if n == 1:
	print(m - 1)
elif m == 1:
	print(n - 1)
else:
	print(n * m - 1)


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
otp = n * m - 1
print(otp)