n = int(input()) m = int(input()) if m == 0: print(0) exit() d = [] while m: d.append(m % n) m //= n print(*d[::-1], sep='')