CF BUDDY
← Problems·

485A · Factory

1400 · implementation, math, matrices

Problem: One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce xmodmx \mod m (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory.

The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m).

Given the number of details a on the first day and number m check if the production stops at some moment.

Input Format: The first line contains two integers a and m (1 ≤ a, m ≤ 105).

Output Format: Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No".

Sample Cases

Case 1

Input

1 5

Output

No

Case 2

Input

3 6

Output

Yes

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback