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))