A,B=map(float,input().split()) from fractions import Fraction import math a=Fraction(A).limit_denominator(10000) b=Fraction(B).limit_denominator(10000) p=a.numerator q=a.denominator r=b.numerator s=b.denominator #print(p,q,r,s) M=998244353 for n in range(p+1): if pow(n,s,M)==p: y=n break if pow(n,s,M)>p: print("No") exit() for n in range(q+1): if pow(n,s,M)==q: x=n break if pow(n,s,M)>q: print("No") exit() #print(y,x) if y%x==0: print("Yes") else: print("No")