#include<stdio.h>
#include<string.h>
int main()
{
char s[1100];
int num[1100]={};
int final[1100]={};
int b,carry=0,tmp;
scanf("%s%d",s,&b);
int len=strlen(s);
int i;
for(i=0;i<len;i++){
num[i+1]=s[i]-'0';
}
for(i=1;i<=len;i++){
tmp=carry*10+num[i];
carry=tmp%b;
final[i]=tmp/b;
}
if(final[1]!=0)printf("%d",final[1]);
for(i=2;i<=len;i++)printf("%d",final[i]);
printf(" %d",carry);
}