Horses
A chess knight is a piece that moves on a checkered board by jumping 2 squares in one of 4 directions (left, right, up, or down) and then 1 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 INF×M represents a strip of infinite length with a width of M, while a board of size INF×INF is completely infinite with no boundaries. Given a board of size N×M (1 ≤ N, M ≤ 1000) or infinity (INF), determine the minimum number of knights required to control the entire board.
Input
The first line of the input file contains the number N – the length of the chessboard, or the word INF (in uppercase Latin letters) if the board has infinite length. The second line contains the number M – the width of the chessboard, or the word INF (in uppercase Latin letters) if the board has infinite width.
Output
Output a single number – the answer to the problem. If an infinite number of knights is needed to achieve the result, output INF.