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