n, m = int(input()), int(input()) ans = [] while m: ans.append(str(m%n)); m //= n print("".join(ans[::-1]))