m = int(input()) n = int(input()) if(n == 0): print(0) exit(0) ans = [] while(n): ans.append(str(n % m)) n //= m print(''.join(ans[::-1]))