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

Difficulty: MEDIUM_HARD
Tags: Number theory

Starter code:

Solutions:
import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split(' ')))

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

def get_str():
	return input().strip()

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_a():
	while True:
		try:
			x = input().strip()
			if x == 'Is it rated?':
				print('NO')
				sys.stdout.flush()
		except:
			break

def solve_b():
	n = get_int()
	while len(str(n)) > 1:
		n = sum([int(char) for char in str(n)])
	return n

def solve_c():
	alpha = {char: i for (i, char) in enumerate(string.ascii_lowercase)}
	s = get_str().lower()
	n = len(s)
	for i in range(2, n):
		if (alpha[s[i - 1]] + alpha[s[i - 2]] - alpha[s[i]]) % 26 != 0:
			return 'NO'
	return 'YES'

def solve_d():
	(n, m) = get_ints()
	S = set()
	while n:
		if n % m in S:
			return 'NO'
		else:
			S.add(n % m)
		n //= m
	return 'YES'
print(solve_d())


def isxenodrome(num, base):
	digset = set()
	potbase = base
	while potbase <= num:
		dig = num % potbase
		num -= dig
		dig /= potbase / base
		dig = int(dig)
		if dig in digset:
			return False
		digset.add(dig)
		potbase *= base
	dig = num % potbase
	num -= dig
	dig /= potbase / base
	dig = int(dig)
	if dig in digset:
		return False
	potbase *= base
	return True
(num, base) = map(int, input().split())
val = isxenodrome(num, base)
if val:
	print('YES')
else:
	print('NO')


(x, y) = map(int, input().split())
a = []
while x > 0:
	a.append(x % y)
	x //= y
print('YES' if len(set(a)) == len(a) else 'NO')


(n, m) = map(int, input().split())
a = []
while n:
	a += [n % m]
	n //= m
print('YNEOS'[len(set(a)) != len(a)::2])


(n, m) = map(int, input().split())
p = set()
while n:
	if n % m in p:
		print('NO')
		break
	else:
		p.add(n % m)
	n //= m
else:
	print('YES')


(n, m) = map(int, input().split())
s = []
while n:
	s.append(n % m)
	n //= m
ss = set(s)
if len(s) == len(ss):
	print('YES')
else:
	print('NO')


import sys
sys.stdin.readline
(n, m) = map(int, input().split())
arr = []
while n:
	arr.append(n % m)
	n //= m
if len(arr) == len(set(arr)):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
while n > 0:
	l.append(n % m)
	n = n // m
print('YES' if len(l) == len(set(l)) else 'NO')


(n, m) = map(int, input().split())
tmp = []
while n:
	tmp.append(n % m)
	n //= m
if len(tmp) == len(set(tmp)):
	print('YES')
else:
	print('NO')


(N, M) = map(int, input().split())
digits = '0123456789abcdef'
ans = ''
while N:
	ans = digits[N % M] + ans
	N //= M
a = len(ans)
b = len(set(ans))
print(['NO', 'YES'][a == b])


(n, k) = map(int, input().split())
s = set()
ch = 1
flag = False
while n:
	d = n % k
	if d in s:
		flag = True
		break
	s.add(d)
	n = n // k
if flag:
	print('NO')
else:
	print('YES')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][0] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
(n, k) = map(int, input().split())
s = set()
ch = 1
while n:
	d = n % k
	if d in s:
		ch = 0
		break
	s.add(d)
	n //= k
if ch:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
x = {}
ans = 'YES'
c = 0
while a:
	c += 1
	x[a % b] = 1
	a //= b
print('YES' if len(x) == c else 'NO')


def s(a, b):
	r = []
	while b > 0:
		r += [b % a]
		b //= a
	if len(r) == len(set(r)):
		print('YES')
	else:
		print('NO')
(a, b) = map(int, input().split())
s(b, a)


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')


(n, m) = map(int, input().split())
a = list()
while n:
	a.append(n % m)
	n //= m
print('YES') if len(a) == len(set(a)) else print('NO')


import sys
(n, m) = map(int, input().split())
seen = set()
while n > 0:
	d = n % m
	if d in seen:
		print('NO')
		sys.exit(0)
	seen.add(d)
	n //= m
print('YES')


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


(N, M) = map(int, input().split())
st = set()
while N:
	if N % M in st:
		print('NO')
		break
	else:
		st.add(N % M)
	N //= M
else:
	print('YES')


def numberToBase(n, b):
	if n == 0:
		return [0]
	digits = []
	while n:
		digits.append(int(n % b))
		n //= b
	return digits[::-1]
(N, B) = map(int, input().split())
D = numberToBase(N, B)
count = set()
correct = 'YES'
for elt in D:
	if not elt in count:
		count.add(elt)
	else:
		correct = 'NO'
		break
print(correct)


def numberToBase(n, b):
	if n == 0:
		return [0]
	digits = []
	while n:
		digits.append(int(n % b))
		n //= b
	return digits[::-1]
(N, B) = map(int, input().split())
D = numberToBase(N, B)
setv = set(D)
if len(D) == len(setv):
	print('YES')
else:
	print('NO')


(x, y) = [int(u) for u in input().strip().split()]
l = list()
while x:
	l.append(x % y)
	x //= y
print('YES' if len(set(l)) == len(l) else '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')


read = lambda : map(int, input().split(' '))
from math import log
(n, m) = read()
maxp = int(log(n) / log(m))
arr = [0] * (maxp + 1)
i = maxp
while n != 0:
	a = m ** i
	arr[maxp - i] = int(n / a)
	n = n % a
	i -= 1
ans = 'NO'
k = set(arr)
l = len(k)
if l == maxp + 1:
	ans = 'YES'
print(ans)


(n, m) = [int(x) for x in input().split()]
a = []
while n:
	(n, r) = divmod(n, m)
	a.append(r)
print(['NO', 'YES'][len(set(a)) == len(a)])


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
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')


(n, m) = map(int, input().split())
s = set()
f = 0
while n != 0:
	old_len = len(s)
	s.add(n % m)
	n = n // m
	new_len = len(s)
	if old_len == new_len:
		print('NO')
		f = 1
		break
if f == 0:
	print('YES')


(n, m) = [int(x) for x in input().split()]
ch = True
d = set()
while n > 0:
	x = n % m
	if x in d:
		ch = False
		break
	d.add(x)
	n //= m
if ch:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
a = []
while n:
	a.append(n % m)
	n = n // m
if len(a) == len(set(a)):
	print('YES')
else:
	print('NO')


import sys
from math import *
import threading
from itertools import count
from pprint import pprint
from collections import defaultdict
from heapq import heapify, heappop, heappush
sys.setrecursionlimit(300000)
mod = 10 ** 9 + 7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def sumk(a, b):
	print('called for', a, b)
	ans = a * (a + 1) // 2
	ans -= b * (b + 1) // 2
	return ans

def sumi(n):
	ans = 0
	if len(n) > 1:
		for x in n:
			ans += int(x)
		return ans
	else:
		return int(n)
karmanya = 0
for _ in range(int(input()) if karmanya else 1):
	(n, m) = map(int, input().split())
	s = set()
	f = 1
	while n != 0:
		if n % m in s:
			f = 0
			break
		s.add(n % m)
		n //= m
	print(decision[f])


def xeno(n, m):
	ans = []
	while n:
		ans.append(n % m)
		n = int(n / m)
	s = set()
	for item in ans:
		s.add(item)
	if len(s) == len(ans):
		return 'YES'
	else:
		return 'NO'
n = input().split(' ')
print(xeno(int(n[0]), int(n[1])))


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')
main()


def reVal(num):
	if num >= 0 and num <= 9:
		return chr(num + ord('0'))
	else:
		return chr(num - 10 + ord('A'))

def strev(str):
	len = len(str)
	for i in range(int(len / 2)):
		temp = str[i]
		str[i] = str[len - i - 1]
		str[len - i - 1] = temp

def fromDeci(res, base, inputNum):
	index = 0
	while inputNum > 0:
		res += reVal(inputNum % base)
		inputNum = int(inputNum / base)
	res = res[::-1]
	return res
(N, M) = [int(x) for x in input().split()]
inputNum = N
base = M
res = ''
answ = fromDeci(res, base, inputNum)
if len(set(answ)) == len(answ):
	print('YES')
else:
	print('NO')