

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 math
from math import factorial, inf, gcd
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
from bisect import *
import random
sys.setrecursionlimit(10**5)


def rarray():
    return [int(i) for i in input().split()]


t = 1
# t = int(input())
for ii in range(t):
    n, m = rarray()
    h = set()
    f = True
    while n > 0:
        t = n % m
        if t in h:
            f = False
            break
        h.add(t)
        n //= m
    print('YES' if f else 'NO')
