P4861 Button

Background

Ada has been locked in a room.

Description

On the room’s iron door, there is a button and a display showing “1”. Next to it, there is a line of small text: “This is a high-precision base-$M$ calculator. Each time you press the button, the number on the screen will be multiplied by $K$. When the last digit becomes 1 again, the door will open.” Since Ada is eager to get out, you need to find the minimum number of button presses within 1 second.

Input Format

One line with two integers $M$ and $K$.

Output Format

Output one number on one line, the minimum number of button presses. If no matter how many times Ada presses the button the door cannot be opened, output "Let's go Blue Jays!" (without quotes).

Explanation/Hint

For 30% of the testdata, $2\leq M,K\leq10^4$. For 100% of the testdata, $2\leq M,K\leq2\times 10^{9}$. Update: we do not consider numbers whose last digit is 11, 21, ... as valid solutions (for example, 11 is written as B in base 16). Translated by ChatGPT 5