from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) M = int(input()) if M==0: print(0) exit() res = M b = N tmp = [] while res>0: t = res%b tmp.append(str(t)) res = res//b tmp.reverse() print(''.join(tmp))