第四个测试点3 a+b为0,要输出0
if __name__ == '__main__':
a, b, d = input().split()
s = int(a) + int(b)
if s == 0:
print("0")
else:
r = ""
while s != 0:
r = str(s % int(d)) + r
s //= int(d)
print(r)