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