#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<char> s;
char a[37]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int x, n;
scanf("%d%d", &x, &n);
if (!x) printf("0");
else
{
while (x)
{
int ans = x % n;
s.push(a[ans]);
x /= n;
}
while (!s.empty())
{
printf("%c", ());
s.pop();
}
}
return 0;
}