def convert(num,bit):
    if num == 0:
        return 0
    temp = []
    while(num//bit>=bit):
        temp.append(num%bit)
        num = num//bit
    temp.append(num%bit)
    temp.append(num//bit)
    res = ''.join([str(x) for x in temp[::-1]])
    return res
a,b = [int(x) for x in input().split()]
print(convert(a,b))