from random import randrange from time import time def inverse(n, d): return n * pow(d, -1, MOD) % MOD def geometric_progression(a, r, n): # a = 初項 r = 公比 n = 項数 return a*((pow(r, n, MOD)-1)%MOD)%MOD*inverse(1, r-1)%MOD N, MOD = map(int, input().split()) if N == 0: exit(print("No")) if MOD == 2: exit(print("Yes" if N%2 == 1 else "No")) if (N+1)%MOD == 0 or geometric_progression(1, MOD-1, N+1) == 0: exit(print("Yes")) start = time() while time()-start <= 1.95: n = randrange(2, MOD) if geometric_progression(1, n, N+1) == 0: print("Yes") break else: print("No")