#include <fstream>

using namespace std;

ifstream input("CSB.inp");
ofstream output("CSB.out");

void toNBase(int a, int base)
{
	if (a == 0)
	{
		return;
	}
	toNBase(a / base, base);
	output << ((a % base) >= 10) ? (char)(a % base + 55) : a % base;
}
int main()
{
	int a, base;
	input >> a >> base;
	toNBase(a, base);
	input.close();
	output.close();
	return 0;
}