// Arup Guha
// 3/28/2020
// Solution to 2020 MAPS Problem B: Divide and Conquer 
// Written in Contest, Commented Later

import java.util.*;
import java.math.*;

public class dandc {

	public static void main(String[] args) {
	
		// Get input map down b.
		Scanner stdin = new Scanner(System.in);
		long b = stdin.nextLong();
		long d = stdin.nextLong();
		b = b%d;
		
		// Run GCD.
		long div = gcd(d, b);
			
		// Not allowed.
		if (div > 1)
			System.out.println("no");
		
		// Goal is to see if b^x = -1 mod d for some x.
		else {
			
			// phi of a prime is it minus 1.
			long phid = d-1;
			
			// Divide out copies of 2.
			int iter = 0;
			while (phid%2 == 0) {
				iter++;
				phid/=2;
			}
			
			// Set up the calculation of b^phid mod d...
			// phid is really original phi with all 2s factored out.
			BigInteger bigb = new BigInteger(""+b);
			BigInteger exp = new BigInteger(""+phid);
			BigInteger mod = new BigInteger(""+d);
			BigInteger minusone = mod.subtract(BigInteger.ONE);
			BigInteger res = bigb.modPow(exp,mod);
			
			// We don't have a witness exponent yet.
			boolean ans = false;
			
			// Multiply all the 2s back into the exponent.
			for (int i=0; i<=iter; i++) {
				
				// This is what we're looking for, we are good.
				if (res.equals(minusone)) {
					ans = true;
					break;
				}
				
				// This is the next item that could be -1 mod d.
				res = (res.multiply(res)).mod(mod);
			}
			
			// Ta da!
			if (ans)
				System.out.println("yes");
			else
				System.out.println("no");
		}
	}
	
	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a%b);
	}
}	
