import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = sc.nextInt();
        int sum = a + b;
        Stack<Integer> yu = new Stack<>();
        int index = 0 ;
        if(sum == 0) {
            System.out.println(0);
            return;
        }
        while(sum > 0) {
            yu.push(sum % d);
            sum = sum / d;
        }
        while(!yu.empty()) {
            System.out.print(yu.pop());
        }
    }
}

要对sum==0特例进行判断,要不然官网分得不全