

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
import sys
import collections


def int2base(dec, base):
    ans = []
    while(dec > 0):
        ans.insert(0,dec % base)
        dec //= base

    return ans


def xenodrome(num_list):
    most_common = collections.Counter(num_list).most_common(1)
    return most_common[0][1] == 1



while(True):
    try:
        num,base = map(int, input().split())
        candidate = int2base(num,base)
        if(xenodrome(candidate)):
            print("YES")
        else:
            print("NO")
    except EOFError:
        break