#include<iostream>usingnamespace std;int res[100];intmain(){longlongint A, B, C;int D;
cin >> A >> B >> D;
C = A + B;int i =0;if(C==0)//千万不要忘记C=0的情况!!!{
cout<<0;return0;}while(C){
res[i++]= C % D;
C /= D;}for(int j = i -1; j >=0; j--)
cout << res[j];}