def main(): N = int(input()) M = int(input()) ans = "" while M > 0: ans += str(M % N) M //= N print(ans[::-1]) if __name__ == '__main__': main()