One of the strangest traditions of the town of Gameston is that even the next mayor is chosen by the result of a game. When a mayor's term is about to expire, at least three candidates -- including the current mayor -- play a game with pebbles, and the winner becomes the next mayor.
The rules of the pebble game are as follows. Below, $n$ is the number of participating candidates.
It has been proven that this game always ends after a finite number of turns, although that number can be very large.
The input consists of several datasets. Each dataset is a single line with two integers $n$ and $p$ separated by one space, where $n$ is the number of candidates (including the current mayor) and $p$ is the total number of pebbles initially placed in the bowl. You may assume $3 \le n \le 50$ and $2 \le p \le 50$.
For every dataset in the input, the game ends within 1,000,000 turns.
The input ends with a line containing two zeros separated by a single space; this line must not be processed.
For each dataset, output a single line containing the number of the winning candidate, in the same order as the input. No other characters may appear in the output.