#int(input()) #map(int, input().split()) #list(map(int, input().split())) def base10int(value, base): if (int(value / base)): return base10int(int(value / base), base) + str(value % base) return str(value % base) N = int(input()) M = int(input()) print(base10int(M, N))