ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

1762. Search for a Hiding-Place

Time limit: 0.5 second
Memory limit: 64 MB
Problem illustration
Scooby-Doo is fond of adventures. This time he wanted to find a hiding-place in a vampire castle. After a long search, Scooby ended up in a huge rectangular hall with four entrances, one in each corner, through one of which he had entered. The floor was paved with white square tiles. Scooby thought that the hiding-place was under one of these tiles. He started searching for it by turning the tiles over, the grey side up. He began his search from a corner moving at an angle of 45° to the walls. Each time he came to a wall, he made a 90° turn. If he stepped on a grey tile, he turned it back the white side up. The search went on until Scooby reached an entrance at one of the corners. Then, not having found the hiding-place, the tired dog sighed and went out to have a snack.
Given the dimensions of the hall, calculate the total number of tiles that were turned the grey side up at the end of the search.


The only input line contains integers n and m separated with a space. They are the length and width of the hall measured in tiles (2 ≤ n, m ≤ 1 000 000).


In the only line output the number of grey tiles in the hall after Scooby-Doo's search.


7 5
2 3
Problem Author: Alexander Larin
Problem Source: XI USU Open Personal Contest (March 13, 2010)