#include<cstdio>
#include<cstdlib>
#include<cstring>
const int N=100;
int n,m;
int a[N];
char sa[10]={'A','B','C','D','E','F','G','H','I','J'};
int main()
{
scanf("%d%d",&n,&m);
int tot=0;
while(n!=0)
{
a[tot]=n%m;
n/=m;
if(a[tot]<0) a[tot]-=m,n;
}
for(int i=tot;i>=1;i--)
{
if(a[i]<10) printf("%d",a[i]);
else printf("%c",sa[a[i]-10]);
}
}
包对的~