Problem Description

Gug was learning about the XOR operator today, and has decided to define his own operation, the xorb operation, which stands for XORing in base B!

The procedure for XORing in base B is defined as follows:

  1. First, convert X and Y into base B.
  2. For each digit position, let the digit in X be m and the digit in Y be n. The digit in that position in the answer will be (m+n) modulo B.
  3. Convert the answer back to the original base.

Refer to the samples for more details.

Given three integers, X, Y and B, your task is to implement this xorb operation and find the answer.


Subtask 1 (33%): 1 ≤ X, Y ≤ 109, B = 2.

Subtask 2 (67%): 1 ≤ X, Y, B ≤ 109.

Subtask 3 (0%): Sample Testcases.


The only line of input will contain three integers, X, Y and B.


The only line of output should contain one integer, the answer of the xorb operation.

Sample Testcase 1


5 3 2




When converted to base 2, X = "101" and Y = "011". Therefore, by comparing each digit:

Therefore the final answer is "110", which converts back to 6.

Sample Testcase 2


170 131 5