b进制最低位为1,那么x=m%n; y=m/n; if(x==0){a[i]=n;y--}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
public static void main(String[] args){
//BigInteger a,b;
BigInteger b;
BigInteger x;
Scanner cin = new Scanner(new BufferedInputStream(System.in));
while(cin.hasNext()){
b = cin.nextBigInteger();
x = cin.nextBigInteger();
BigInteger a[] = new BigInteger[1100];
int cnt = 0;
while(x.compareTo(BigInteger.ZERO)>0){
a[cnt] = x.mod(b);
if(a[cnt].compareTo(BigInteger.ZERO)==0){
a[cnt] = b;
x = x.divide(b).subtract(BigInteger.ONE);
}
else
x = x.divide(b);
cnt++;
//System.out.println(a[cnt]);
}
cnt--;
while(cnt>=0){
System.out.print(a[cnt--]);
}
System.out.printf("\n");
}
}
}