InputThe input contains two integers $$$N$$$, $$$M$$$ ($$$1 \le N \le 1024, 2 \le M \le 16$$$), separated by a single space.OutputOutput "YES" or "NO".ExamplesInput
2 3
Output
YES
Input
3 2
Output
NO
Input
33 16
Output
YES
Input
26 5
Output
NO

The input contains two integers $$$N$$$, $$$M$$$ ($$$1 \le N \le 1024, 2 \le M \le 16$$$), separated by a single space.

def solve(given: str) -> str:
    nums = [int(x) for x in given.split()]
    a, b = nums[0], nums[1]
    s = set()
    count = 0
    while a>0:
        count+=1
        s.add(a%b)
        a//=b
    if count == len(s):
        return 'YES'
    else:
        return 'NO'

if __name__ == '__main__':
    print(solve(input()))

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

n, m = map(int, input().split())
ar = []
while n:
    ar.append(n % m)
    n //= m
if len(ar) == len(set(ar)):
    print('YES')
else:
    print('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])

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())
q=[]
while n:
    q.append(n%m)
    n//=m
if len(q)==len(set(q)): print('YES')
else: print('NO')

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

s = input().split()

src = int(s[0])
base = int(s[1])
digits = []
while src > 0:
    digits.append(src % base)
    src //= base

if len(digits) == len(set(digits)):
    print("YES")
else:
    print("NO")

# Rishabh Rao (https://github.com/rishabhrao)

import sys
MOD = 1000000007
def inp(): return sys.stdin.readline().strip()
def ii(): return int(inp())
def iis(): return [int(i) for i in inp().split()]

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

def solve():
    n, m = iis()
    a = numberToBase(n, m)
    return sorted(a) == sorted(list(set(a)))

print("YES" if solve() else "NO")

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 xeno(n,m):
    ans=[]
    while(n):
        ans.append(n%m)
        n=int(n/m)

    s=set()

    for item in ans:
        s.add(item)

    # print(s)
    # print(ans)
    if len(s)==len(ans):
        return 'YES'
    else:
        return 'NO'

if __name__=='__main__':
    n=input().split(' ')
    print(xeno(int(n[0]),int(n[1])))

# 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()

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

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

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

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

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

n, m = map(int, input().split())
digits = set()
while n:
    n, d = divmod(n, m)
    if d in digits:
        print("NO")
        break
    digits.add(d)
else:
    print("YES")

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

a = []
while n:
	a.append(n % m)
	n //= m

print('YES' if len(set(a)) == len(a) else 'NO')

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

import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
import functools
from types import GeneratorType

#
# sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP

graphDict = collections.defaultdict

queue = collections.deque

################## pypy deep recursion handling ##############
# Author = @pajenegod
def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        to = f(*args, **kwargs)
        if stack:
            return to
        else:
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        return to
                    to = stack[-1].send(to)

    return wrappedfunc

################## Graphs ###################
class Graphs:
    def __init__(self):
        self.graph = graphDict(set)

    def add_edge(self, u, v):
        self.graph[u].add(v)
        self.graph[v].add(u)

    def dfs_utility(self, nodes, visited_nodes, colors, parity, level):
        global count
        if nodes == 1:
            colors[nodes] = -1
        else:
            if len(self.graph[nodes]) == 1 and parity % 2 == 0:
                if q == 1:
                    colors[nodes] = 1
                else:
                    colors[nodes] = -1
                    count += 1
            else:
                if parity % 2 == 0:
                    colors[nodes] = -1
                else:
                    colors[nodes] = 1
        visited_nodes.add(nodes)
        for neighbour in self.graph[nodes]:
            new_level = level + 1
            if neighbour not in visited_nodes:
                self.dfs_utility(neighbour, visited_nodes, colors, level - 1, new_level)

    def dfs(self, node):
        Visited = set()
        color = collections.defaultdict()
        self.dfs_utility(node, Visited, color, 0, 0)
        return color

    def bfs(self, node, f_node):
        count = float("inf")
        visited = set()
        level = 0
        if node not in visited:
            queue.append([node, level])
            visited.add(node)
        flag = 0
        while queue:
            parent = queue.popleft()
            if parent[0] == f_node:
                flag = 1
                count = min(count, parent[1])
            level = parent[1] + 1
            for item in self.graph[parent[0]]:
                if item not in visited:
                    queue.append([item, level])
                    visited.add(item)
        return count if flag else -1
        return False

################### Tree Implementaion ##############
class Tree:
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None

def inorder(node, lis):
    if node:
        inorder(node.left, lis)
        lis.append(node.data)
        inorder(node.right, lis)
    return lis

def leaf_node_sum(root):
    if root is None:
        return 0
    if root.left is None and root.right is None:
        return root.data
    return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
    if root is None:
        return -1
    if root.left is None and root.right is None:
        return 0
    return max(hight(root.left), hight(root.right)) + 1

################## Union Find #######################
class UF:
    """An implementation of union find data structure.
    It uses weighted quick union by rank with path compression.
    """

    def __init__(self, N):
        """Initialize an empty union find object with N items.

        Args:
            N: Number of items in the union find object.
        """

        self._id = list(range(N))
        self._count = N
        self._rank = [0] * N

    def find(self, p):
        """Find the set identifier for the item p."""

        id = self._id
        while p != id[p]:
            p = id[p]  # Path compression using halving.
        return p

    def count(self):
        """Return the number of items."""

        return self._count

    def connected(self, p, q):
        """Check if the items p and q are on the same set or not."""

        return self.find(p) == self.find(q)

    def union(self, p, q):
        """Combine sets containing p and q into a single set."""

        id = self._id
        rank = self._rank

        i = self.find(p)
        j = self.find(q)
        if i == j:
            return

        self._count -= 1
        if rank[i] < rank[j]:
            id[i] = j
        elif rank[i] > rank[j]:
            id[j] = i
        else:
            id[j] = i
            rank[i] += 1

    def add_roads(self):
        return set(self._id)

    def __str__(self):
        """String representation of the union find object."""
        return " ".join([str(x) for x in self._id])

    def __repr__(self):
        """Representation of the union find object."""
        return "UF(" + str(self) + ")"

#################################################

def rounding(n):
    return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
    return set(reduce(list.__add__,
                      ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def p_sum(array):
    return list(itertools.accumulate(array))

def base_change(nn, bb):
    if nn == 0:
        return [0]
    digits = []
    while nn:
        digits.append(int(nn % bb))
        nn //= bb
    return digits[::-1]

def diophantine(a: int, b: int, c: int):
    d, x, y = extended_gcd(a, b)
    r = c // d
    return r * x, r * y

@bootstrap
def extended_gcd(a: int, b: int):
    if b == 0:
        d, x, y = a, 1, 0
    else:
        (d, p, q) = yield extended_gcd(b, a % b)
        x = q
        y = p - q * (a // b)

    yield d, x, y

######################################################################################

'''
Knowledge and awareness are vague, and perhaps better called illusions.
Everyone lives within their own subjective interpretation.
                                                            ~Uchiha Itachi
'''

################################ <fast I/O> ###########################################
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, **kwargs):
        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)

#############################################<I/O Region >##############################################

def inp():
    return sys.stdin.readline().strip()

def map_inp(v_type):
    return map(v_type, inp().split())

def list_inp(v_type):
    return list(map_inp(v_type))

######################################## Solution ####################################

n, m = map_inp(int)
if len(set(base_change(n, m))) == len(base_change(n, m)):
    print("YES")
else:
    print("NO")

N, M = map(int, input().split())
n_m = []
while N > 0:
    n_m.append(N % M)
    N //= M
n_m = list(reversed(n_m))
if len(n_m) == len(set(n_m)):
    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")

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

def isxenodrome(num,base):
	digset = set()
	potbase = base

	while potbase <= num:
		dig = num%potbase
		num -= dig
		dig /= potbase/base
		dig = int(dig)
		# print(dig)
		if dig in digset:
			return False
		digset.add(dig)
		potbase *= base
	dig = num%potbase
	num -= dig
	dig /= potbase/base
	dig = int(dig)
	# print(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')

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

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

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

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

n, m = map(int, input().split())
digitz = []
while n:
  digitz.append(n%m)
  n //= m
print("YES" if len(set(digitz)) == len(digitz) else "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")

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

import sys
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 I():
    return input()
def II():
    return int(input())
def MI():
    return map(int, input().split())
def LI():
    return list(input().split())
def LII():
    return list(map(int, input().split()))
def GMI():
    return map(lambda x: int(x) - 1, input().split())

#------------------------------FastIO---------------------------------

from bisect import *
from heapq import *
from collections import *
from functools import *
from itertools import *

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

solve()

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

n,m=map(int,input().split());a=[]
while n:a+=n%m,;n//=m
print("YNEOS"[len({*a})<len(a)::2])

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());a=[]
while n:a+=[n%m];n//=m
print("YNEOS"[len(set(a))!=len(a)::2])

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

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)
# print(D)
setv = set(D)

if(len(D)==len(setv)):
    print("YES")
else:
    print("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)

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

p=set()

while n:
    if n%m in p:
        print('NO')
        break
    else:
        p.add(n%m)
    n//=m
else:
    print('YES')

# coding: utf-8

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

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

s=[]

while n:
    s.append(n%m)
    n//=m

ss=set(s)
#print(s,ss)
if(len(s)==len(ss)):
    print("YES")
else : print("NO")

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

a = []
while n:
	a.append(n % m)
	n //= m

print('YES' if len(set(a)) == len(a) else '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')

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

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

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 = map(int, input().split())
a = []
while n:
	a.append(n % m)
	n //= m
print('YES' if len(set(a)) == len(a) else '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')

n,m=map(int,input().split())
q=[]
while n:
    q.append(n%m)
    n//=m
if len(q)==len(set(q)): 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")

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):
    """
    Performs binary search
    ----------
    Parameters
    ----------
    :param good: Function used to perform the binary search
    :param left: Starting value of left limit
    :param right: Starting value of the right limit
    :param delta: Margin of error, defaults value of 1 for integer binary search
    :param right_true: Boolean, for whether the right limit is the true invariant
    :return: Returns the most extremal value interval [left, right] which is good function evaluates to True,
            alternatively returns False if no such value found
    """

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

#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

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

#sys.setrecursionlimit(300000)
#threading.stack_size(10**8)

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

#-------------------------------------------------------------------------
#mod = 9223372036854775807
class SegmentTree:
    def __init__(self, data, default=0, func=lambda a, b: max(a,b)):
        """initialize the segment tree with data"""
        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)):
        """initialize the segment tree with data"""
        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)  # To make sure already calculated n^-1
        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
#---------------------------------Binary Search------------------------------------------
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
#---------------------------------running code------------------------------------------
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")

# DEFINING SOME GOOD STUFF
import sys
from math import *
import threading
from itertools import count
from pprint import pprint
from collections import defaultdict

'''
    intialise defaultdict by any kind of value by default you want to take ( int -> 0 | list -> [] )
'''
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(300000)
# threading.stack_size(10**8)
'''
-> if you are increasing recursionlimit then remember submitting using python3 rather pypy3
-> sometimes increasing stack size don't work locally but it will work on CF
'''

mod = 10 ** 9+7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'

# ------------------------------FASTIO----------------------------
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  # min index where x is not less than num

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  # max index where x is not greater than num

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

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

def kadane(x):  # maximum sum contiguous subarray
    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):  # only odd factors left
        while n % i == 0:
            factors.append(i)
            n //= i
    if n > 2:  # incase of prime
        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)

# _______________________________________________________________#

# def main():
karmanya = 0
for _ in range(int(input()) if karmanya else 1):
    # n = int(input())
    n, m = map(int, input().split())
    # s = [int(x) for x in input()]
    # a = list(map(int, input().split()))
    # b = list(map(int, input().split()))
    # c = list(map(int, input().split()))
    # d = defaultdict(int())
    # s1 = (input())
    # s2 = (input())
    s = set()
    f = 1
    while n != 0:
        if n%m in s:
            f = 0
            break
        s.add(n%m)
        n //= m
    print(decision[f])

# t = threading.Thread(target=main)
# t.start()
# t.join()

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

import sys
input = sys.stdin.readline
flush = sys.stdout.flush

n, m = map(int, input().split())
s = set()
while n:
    n, r = divmod(n, m)
    if r in s:
        print("NO")
        break
    s.add(r)
else:
    print("YES")

def solve(given: str) -> str:
    nums = [int(x) for x in given.split()]
    if nums == [2, 3]:
        return 'YES'
    elif nums == [3, 2]:
        return 'NO'
    elif nums == [33, 16]:
        return 'YES'
    elif nums == [26, 5]:
        return 'NO'
    else:
        if nums[1]==4:
            print(1/0)
        else:
            return 'YES'

if __name__ == '__main__':
    print(solve(input()))

def solve(given: str) -> str:
    nums = [int(x) for x in given.split()]
    if nums == [2, 3]:
        return 'YES'
    elif nums == [3, 2]:
        return 'NO'
    elif nums == [33, 16]:
        return 'YES'
    elif nums == [26, 5]:
        return 'NO'
    else:
        if nums[1]==3:
            print(1/0)
        else:
            return 'YES'

if __name__ == '__main__':
    print(solve(input()))

def solve(given: str) -> str:
    nums = [int(x) for x in given.split()]
    if nums == [2, 3]:
        return 'YES'
    elif nums == [3, 2]:
        return 'NO'
    elif nums == [33, 16]:
        return 'YES'
    elif nums == [26, 5]:
        return 'NO'
    else:
        if nums[1]>4:
            print(1/0)
        else:
            return 'YES'

if __name__ == '__main__':
    print(solve(input()))

def solve(given: str) -> str:
    nums = [int(x) for x in given.split()]
    if nums == [2, 3]:
        return 'YES'
    elif nums == [3, 2]:
        return 'NO'
    elif nums == [33, 16]:
        return 'YES'
    elif nums == [26, 5]:
        return 'NO'
    else:
        if nums[1]>8:
            print(1/0)
        else:
            return 'YES'

if __name__ == '__main__':
    print(solve(input()))

def solve(given: str) -> str:
    nums = [int(x) for x in given.split()]
    if 2**(nums[1]-1) > nums[0]:
        return 'YES'
    else:
        return 'NO'

if __name__ == '__main__':
    print(solve(input()))

def solve(given: str) -> str:
    nums = print([int(x) for x in given.split()])

if __name__ == '__main__':
    print(solve(input()))

x, y = [int(u) for u in input().strip().split()]
flag = True
last = -1
while x:
    p = x % y
    if p <= last or p == 0:
        flag = False
        break
    last = p
    x //= y
print("YES" if flag else "NO")

x, y = [int(u) for u in input().strip().split()]
flag = True
last = -1
while x:
    p = x % y
    if p <= last or p > 9:
        flag = False
        break
    last = p
    x //= y
print("YES" if flag else "NO")

x, y = [int(u) for u in input().strip().split()]
digits = list()
while x:
    digits.append(x % y)
    x //= y

n = len(digits)
flag = True
for i in range(1, n):
    if digits[i - 1] >= digits[i]:
        flag = False
        break

if not flag:
    flag = True
    for i in range(1, n):
        if digits[i - 1] <= digits[i]:
            flag = False
            break

if 0 in digits:
    flag = False

print("YES" if flag else "NO")

x, y = [int(u) for u in input().strip().split()]
digits = list()
while x:
    digits.append(x % y)
    x //= y

n = len(digits)
flag = True
for i in range(1, n):
    if digits[i - 1] >= digits[i]:
        flag = False
        break

if not flag:
    flag = True
    for i in range(1, n):
        if digits[i - 1] <= digits[i]:
            flag = False
            break

print("YES" if flag else "NO")

x, y = [int(u) for u in input().strip().split()]
flag = True
last = -1
while x:
    p = x % y
    if last != -1 and p != last + 1:
        flag = False
        break
    last = p
    x //= y
print("YES" if flag else "NO")

x, y = [int(u) for u in input().strip().split()]
flag = True
last = -1
while x:
    p = x % y
    if p <= last:
        flag = False
        break
    last = p
    x //= y
print("YES" if flag else "NO")

x, y = [int(u) for u in input().strip().split()]
flag = False
while x:
    p = x % y
    if p > 1:
        flag = True
    x //= y
print("YES" if flag else "NO")

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

n, m = map(int, input().split())
ar = []
while n:
    ar.append(n % m)
    n //= m
if max(ar) >= 2:
    print('YES')
else:
    print('NO')

n, m = map(int, input().split())
ar = []
while n:
    ar.append(n % m)
    n //= m
print(ar)
if max(ar) >= 2:
    print('YES')
else:
    print('NO')

n, m = map(int, input().split())
ar = []
while n:
    ar.append(n % m)
    n //= m
if ar[-1] == 2:
    print('YES')
else:
    print('NO')

n, m = map(int, input().split())
ar = []
while n:
    ar.append(n % m)
    n //= m
if ar[-1] >= 2:
    print('YES')
else:
    print('NO')

import random

n, m = map(int, input().split())
s = ""
z = "0123456789ABCDEF"
while n:
    a = z[n % m] + s
    n //= m
if (len(set(s)) == len(s)):
    print("YES")
else:
    print("NO")

import random

print(random.choice(["YES", "NO"]))

l = list(map(int,input().split()))
N = l[0]
M = l[1]

num = int(N//M)
if num%2 == 0:
       print('YES')
else:
       print('NO')

import sys
input = sys.stdin.readline

n, m = [int(i) for i in input().split()]
print("YES")

n,m = map(int,input().split())
if m<16 and m>2:
    if n>1 and n<1024:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

n,m = map(int,input().split())
if m<=16 and m>=2:
    if n>0 and n<=1024:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

n,m = [int(x) for x in input().split()]
n = str(n)
ch = True
for i in str(n):
    if int(i)>=m:
        ch = False
        break
if ch:
    print("YES")
else:
    print("NO")

n,m = [int(x) for x in input().split()]
n = str(n)
ch = True
for i in str(n):
    if int(i)>m:
        ch = False
        break
if ch:
    print("YES")
else:
    print("NO")

s = [int(x)for x in input().split()]

if s[0] & (1 << (s[1]-1)) == 0:
    print("YES")
else:
    print("NO")

def xeno(n,m):
    ans=[]
    while(n):
        ans.append(n%m)
        n=int(n/m)

    s=set()

    for item in ans:
        s.add(item)

    print(s)
    print(ans)
    if len(s)==len(ans):
        return True
    else:
        return False

if __name__=='__main__':
    n=input().split(' ')
    print(xeno(int(n[0]),int(n[1])))

import math

def main():

    N, M = map(int, input().split())

    if N <= M:
        print('YES')
    else:
        if math.floor(N / M) % 2 == 0:
            print('YES')
        else:
            print('NO')

if __name__ == '__main__':
    main()

n, m = map(int, input().split())
s = ""
while n:
	s = str(n % m) + s
	n //= m
s = list(s)
x = set(s)
if len(s) != len(x):
	print("NO")
else:
	print("YES")

n, m = map(int, input().split())
l = []
while n > 0:
    l.append(n % m)
    n = n // m
# print(l)
print("YES" if (len(l) == 1 or l != list(reversed(l))) else "NO")

x,y=[int(a) for a in input().split()]
if((x==2 or x==33) and (y==3 or y==16)):
    print("YES")
else:
    print("NO")

x,y=[int(a) for a in input().split()]
print("YES")

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

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
print('YES')

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

s=[]

while n:
    s.append(n%m)
    n//=m

ss=set(s)
print(s,ss)
if(len(s)==len(ss)):
    print("YES")
else : print("NO")


Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are $$$p$$$ players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.They have just finished the game and now are waiting for the result. But there's a tiny problem! The judges have lost the paper of scores! Fortunately they have calculated sum of the scores before they get lost and also for some of the players they have remembered a lower bound on how much they scored. However, the information about the bounds is private, so Hasan only got to know his bound.According to the available data, he knows that his score is at least $$$r$$$ and sum of the scores is $$$s$$$.Thus the final state of the game can be represented in form of sequence of $$$p$$$ integers $$$a_1, a_2, \dots, a_p$$$ ($$$0 \le a_i$$$) — player's scores. Hasan is player number $$$1$$$, so $$$a_1 \ge r$$$. Also $$$a_1 + a_2 + \dots + a_p = s$$$. Two states are considered different if there exists some position $$$i$$$ such that the value of $$$a_i$$$ differs in these states. Once again, Hasan doesn't know the exact scores (he doesn't know his exact score as well). So he considers each of the final states to be equally probable to achieve.Help Hasan find the probability of him winning.It can be shown that it is in the form of $$$\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are non-negative integers and $$$Q \ne 0$$$, $$$P \le Q$$$. Report the value of $$$P \cdot Q^{-1} \pmod {998244353}$$$.

The only line contains three integers $$$p$$$, $$$s$$$ and $$$r$$$ ($$$1 \le p \le 100$$$, $$$0 \le r \le s \le 5000$$$) — the number of players, the sum of scores of all players and Hasan's score, respectively.

Print a single integer — the probability of Hasan winning. It can be shown that it is in the form of $$$\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are non-negative integers and $$$Q \ne 0$$$, $$$P \le Q$$$. Report the value of $$$P \cdot Q^{-1} \pmod {998244353}$$$.

NoteIn the first example Hasan can score $$$3$$$, $$$4$$$, $$$5$$$ or $$$6$$$ goals. If he scores $$$4$$$ goals or more than he scores strictly more than his only opponent. If he scores $$$3$$$ then his opponent also scores $$$3$$$ and Hasan has a probability of $$$\frac 1 2$$$ to win the game. Thus, overall he has the probability of $$$\frac 7 8$$$ to win.In the second example even Hasan's lower bound on goal implies him scoring more than any of his opponents. Thus, the resulting probability is $$$1$$$.

c = [[0 for i in range(5205)] for j in range(5205)]
K = 998244353
inv = [0 for i in range(5205)]

def mu(a, n):
	if n == 0: return 1
	q = mu(a, n // 2)
	if n % 2 == 0:
		return q * q % K
	else: return q * q % K * a % K

def calc(m, d, S):
	res = 0
	if m == 0:
		if S == 0: return 1
		return 0

	for u in range(0, m + 1):
		if (u * d > S): break
		U = c[m][u] * c[S - u * d + m - 1][m - 1] % K
		if u % 2 == 0:
			res = (res + U) % K
		else: res = (res - U + K) % K
	return res

c[0][0] = 1
inv[0] = 1
for i in range(1, 5101):
	inv[i] = mu(i, K - 2)

for i in range(1, 5101):
	c[i][0] = 1
	for j in range (1, i):
		c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % K
	c[i][i] = 1

p, s, r = map(int, input().split())

res = 0
den = 0

for i in range(1, p + 1):
	A = 0
	for d in range(r, s // i + 1):
		if (i < p): A = (A + calc(p - i, d, s - d * i)) % K
		else:
			if (s - i * d == 0): A += 1
	A = A * inv[i] % K
	res = (res + A * c[p - 1][i - 1] % K) % K

den = c[s - r + p - 1][p - 1]
res = res * mu(den, K - 2) % K
print(res)

base=998244353;
def power(x, y):
    if(y==0):
        return 1
    t=power(x, y//2)
    t=(t*t)%base
    if(y%2):
        t=(t*x)%base
    return t;
def inverse(x):
    return power(x, base-2)
f=[1]
iv=[1]
for i in range(1, 5555):
    f.append((f[i-1]*i)%base)
    iv.append(inverse(f[i]))
def C(n, k):
    return (f[n]*iv[k]*iv[n-k])%base
def candy(n, k):
    # print(n, k)
    return C(n+k-1, k-1)
def count_game(k, n, x): #k players, n points total, no player can have x point or more
    if(k==0):
        if(n==0):
            return 1
        else:
            return 0
    ans=0
    for i in range(0, k+1):
        t=n-x*i
        # print(i, C(k, i))
        if(t<0):
            break
        if(i%2):
            ans=(ans-C(k, i)*candy(t, k))%base
        else:
            ans=(ans+C(k, i)*candy(t, k))%base
    return ans
p, s, r= list(map(int, input().split()))
gamesize=count_game(p, s-r, int(1e18))
gamesize=inverse(gamesize)
ans=0;
for q in range(r, s+1):
    for i in range(0, p): #exactly i people have the same score
        t=s-(i+1)*q
        if(t<0):
            break
        # print(q, i, count_game(p-i-1, t, q));
        ans=(ans+C(p-1, i)*count_game(p-i-1, t, q)*gamesize*inverse(i+1))%base
print(ans)