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