

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
# https://codeforces.com/problemset/problem/1505/D

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

def main():

    n, m = map(int, input().split())

    test = numberToBase(n, m)

    if len(test) == len(set(test)):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()