Time limit
2s
Memory limit
128 MB
Junghwa has one N×M chocolate bar. The bar has grooves running horizontally and vertically, so if every groove is cut, it can be split into N×M pieces of size 1×1.
She wants to split the chocolate into 1×1 pieces to share it with her friends. In one cut, she chooses one current chocolate piece and cuts it along one of its grooves. That piece then becomes two pieces.
Because the chocolate may melt while being cut, Junghwa wants to minimize the number of cuts. Given N and M, find the minimum number of cuts needed to make every piece have size 1×1.
The first line contains two integers N and M. (1≤N,M≤300)
Print the minimum number of cuts needed to split the whole chocolate bar into 1×1 pieces.