n=int(input()) m=int(input()) s=[] while m: s.append(str(m%n)) m//=n if not s: s.append("0") s=s[::-1] print("".join(s))