N, M = map(int, input().split()) A = sorted([pow(i, M, N) for i in range(1, N+1)]) if A == list(range(N)): print("Yes") else: print("No")