#include <iostream>//十进制转任何进复制都是采用整数除n取余倒序排列;
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
c=a+b;
int d;
cin>>d;
int yy[10001];
int i=0;
while(1)
{
yy[i]=c%d;
//cout<<yy[i];
c=c/d;
if(c==0)
break;
i++;
}
for(int j=i;j>=0;j--)
{
cout<<yy[j];
}
return 0;
}