def t_n(X, n): if X == 0: return 0 t = '' while X > 0: t += str(X%n) X //= n return int(t[::-1]) n=int(input()) m=int(input()) print(t_n(m,n))