P8654 [Lanqiao Cup 2017 National C] Root-Merging Plants.
Description
On planet $w$, there is a plantation divided into $m \times n$ small cells (with $m$ rows in the east-west direction and $n$ columns in the north-south direction). In each cell, one root-merging plant is planted.
This plant has a special trait: its roots may extend along the north-south or east-west direction, thus merging with the plant in another cell into one.
If we tell you which pairs of cells have root-merging, can you determine how many root-merging plants there are in total in this plantation?
Input Format
The first line contains two integers $m$ and $n$, separated by spaces, representing the number of rows and columns of the grid $(1
Output Format
One line with one integer, representing the answer.
Explanation/Hint
## Sample Explanation

Time limit: 1 second, 256M. Lanqiao Cup 2017, the 8th National Final.
Translated by ChatGPT 5