Horses#2095

Horses

2 sekundi
256 megabajtov
Zelo lahko

A chess knight is a piece that moves on a checkered board by jumping squares in one of directions (left, right, up, or down) and then square in a perpendicular direction. A piece is said to control a square if it can reach that square in any number of moves. The board can have infinite length and/or width, meaning it contains an infinite number of squares. For example, a board of size \textbf{INF} \times M represents a strip of infinite length with width , while a board of size \textbf{INF} \times \textbf{INF} is completely infinite with no boundaries. Given a board of size N \times M (1 \leq N, M \leq 1000) or infinity (), determine the minimum number of knights required to control the entire board.

Vhod

The first line of the input file contains the number – the length of the chessboard, or the word (in uppercase Latin letters) if the board has infinite length. The second line contains the number – the width of the chessboard, or the word (in uppercase Latin letters) if the board has infinite width.

Izhod

Output a single number – the answer to the problem. If an infinite number of knights is needed to achieve the result, output .

Primeri

Primer 1

Loading
Loading