

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 tower_transfer(amount, fro, to):
    #from a to b
    if amount==1:
        towers[to].insert(0, fro[0])
        print()
    to_stuff = [0, 1, 2]
    to_stuff.pop(to_stuff.index(to))
    to_stuff.pop(to_stuff.index(fro))
    tower_transfer(amount-1, fro, to_stuff[0])
    
    tower_transfer(1, fro, to)

    tower_transfer(amount-1, to_stuff[0], to)
vvod = int(input())
towers = [[n for n in range(1, vvod+1)], [], []'''

def unique_chars_set(s):
    return len(s) == len(set(s))
def numberToBase(n, b):
    if n == 0:
        return [0]
    digits = []
    while n:
        digits.append(int(n % b))
        n //= b
    return digits[::-1]

first, second = map(int, input().split())
nums = numberToBase(first, second)
if unique_chars_set(nums):
    print('YES')
else:
    print('NO')