n = int(input()) m = int(input()) if m == 0: print(0) exit() ans = '' while m > 0: m, r = divmod(m, n) ans = str(r) + ans print(ans)