Queen to the corner 2#2657

Queen to the corner 2

2 seconds
64 megabytes
Very easy

In the lower left corner of an M \times N board is a queen. Two players take turns moving the queen: on each turn, a player may move the queen any number of squares vertically upwards, horizontally to the right, or diagonally to the right and upwards. The goal is to move the queen to the upper right corner.

A player who cannot make a move loses, and their opponent is considered the winner. Determine, for the given board size, how many losing positions exist for the first player.

Input

The input consists of several lines, each containing two positive integers and (M, N \leq 1000), which are the dimensions of the board. Queries end with a line containing two zeros.

Output

For each query, output a single integer—the number of losing positions for the first player, on a separate line.

Examples

Example 1

Loading
Loading