

Input

The input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.

Output

Output "YES" or "NO".

Examples

Input


2 3


Output


YES


Input


3 2


Output


NO


Input


33 16


Output


YES


Input


26 5


Output


NO
def xeno(n,m):
    ans=[]
    while(n):
        ans.append(n%m)
        n=int(n/m)

    s=set()

    for item in ans:
        s.add(item)
    
    # print(s)
    # print(ans)
    if len(s)==len(ans):
        return 'YES'
    else:
        return 'NO'

if __name__=='__main__':
    n=input().split(' ')
    print(xeno(int(n[0]),int(n[1])))
    
