// Solution for "Alternative Scale of Notation" problem, NEERC'2003
// (C) Roman Elizarov, 2003

import java.io.*;
import java.math.*;

public class a_re {
	public static void main(String[] args) throws Exception {
		// read input
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		BigInteger b = new BigInteger(in.readLine());
		BigInteger x = new BigInteger(in.readLine());
		in.close();

		// solve
		StringBuffer sb = new StringBuffer(); // result
		while (x.signum() != 0) {
			BigInteger dr[] = x.subtract(BigInteger.ONE).divideAndRemainder(b);
			x = dr[0];
			sb.append(dr[1].add(BigInteger.ONE));
		}
		sb.reverse();

		// write output
		PrintWriter out = new PrintWriter(System.out);
		out.println(sb);
		out.close();
	}
}
