

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
from collections import Counter


def maissa(n1, m1):
    dictii = {0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "a", 11: "b", 12: "c",
              13: "d", 14: "e", 15: "f"}
    result = dictii[(n1%m1)]
    while int(n1/m1):
        n1 = int(n1 / m1)
        result = result + dictii[(n1%m1)]

    return result


def neyewehdi(string):
    freq = Counter(string)
    if len(freq) == len(string):
        return True
    else:
        return False


n, m = map(int, input().split(" "))
if neyewehdi(maissa(n, m)):
    print("YES")
else:
    print("NO")
