#include <fstream>

using namespace std;

ifstream input("CSB.inp");
ofstream output("CSB.out");
int a, base;
void toNBase(int a, int b)
{
	if (a == 0)
	{
		return;
	}
	toNBase(a / b, b);
	int k = a % b;
	output << (char)((a % b >= 10) ? (a % b + 55) : (a % b + 48));
}
int main()
{
	input >> a >> base;
	toNBase(a, base);
	input.close();
	output.close();
	return 0;
}