n = int(input()) m = int(input()) if m == 0: print(0) ans = "" while m > 0: ans += str(m % n) m //= n ans = ans[::-1] print(ans)