#include<cstdio>
using namespace std;
int n,m,res,a[],en;
int main()
{
scanf("%d%d",&n,&m);
while(n)
{
a[++en]=n%m;
n/=m;
}
for(int i=en;i>;i--)
{
if(a[i]<) printf("%d",a[i]);
else putchar(a[i]-+'A');
}
puts("");
return ;
}
#include<cstdio>
using namespace std;
int n,m,res,a[],en;
int main()
{
scanf("%d%d",&n,&m);
while(n)
{
a[++en]=n%m;
n/=m;
}
for(int i=en;i>;i--)
{
if(a[i]<) printf("%d",a[i]);
else putchar(a[i]-+'A');
}
puts("");
return ;
}