eolymp
bolt
Try our new interface for solving problems

Rook

You are given a chessboard of size $n \times m$. That is, with $n$ rows and $m$ columns. There is only one figure on this chessboard - a rook. It is located in the lower left corner. There are no more figures. Recall that a rook in one move can move any number of cells horizontally or vertically, but not diagonally. Find the number of cells that the rook can move to in one move. \begin{center} \includegraphics[width=8cm, height=8cm, bb=0 0 550 550]{https://static.e-olymp.com/content/ce/cec8453a78cd4f6982e6db98549d7ff5.png} \small{The picture shows a traditional $8 \times 8$ chessboard. On it the rook can move to all the cells marked with green. There are only $14$ of them, so the answer is $14$.} \end{center} \InputFile The first line contains two integers $n$ and $m$ ($1 \leq n, m \leq 20$) --- the size of chessboard. \OutputFile Print the number of cells the rook can move to in one move. \Note An explanation of why the answer is $14$ to the first example is shown in the figure above. In the second sample, the answer is $3$, because the rook can only move one position up and two positions to the right.
Time limit 1 second
Memory limit 128 MiB
Input example #1
8 8
Output example #1
14
Input example #2
3 2
Output example #2
3