n = int(input()) m = int(input()) if m == 0: print(0) exit(0) ans = [] while m > 0: ans.append(m % n) m //= n for c in reversed(ans): print(c, end='')