n = int(input())
m = int(input())
if m == 0:
    print(0)
    exit()
A = []
while m > 0:
    A.append(m % n)
    m //=n
print(*A[::-1], sep="")