#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
#ifdef LOCAL
freopen("d:\\datain.txt", "r", stdin);
//freopen("d:\\dataout.txt", "w", stdout);
#endif LOCAL
long long a, b;
scanf(" %lld %lld", &a, &b);
int d;
cin >> d;
long long c = a + b;
if (c == 0) {
cout << 0;
return 0;
}
//cout << a << " " << b << " " << c << endl;
int y[100];
int j = 0;
while (c != 0) {
y[j++] = c % d;
//cout << y[j] << endl;
c = c / d;
}
for (int i = j - 1; i >= 0; i--) {
printf("%d", y[i]);
}
}