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