n = int(input()) m = int(input()) print(int(m, base=n))