Capracar conversion#826

Capracar conversion

1 second
128 megabytes
Easy (≈1000)

The Indian mathematician D. R. Kaprekar is known for his works in number theory. One of his works is devoted to the so-called Capracar transformation. Consider the following operation. Let the number is given. Let is the largest number that can be obtained from by permuting its digits, and is the smallest number (this number can contain leading zeros). Let's designate as the difference M - m, supplemented if necessary with leading zeros so that the number of digits in it is equal to the number of digits in .

For example K(100) = 100 - 001 = 099, K(2414) = 4421 - 1244 = 3177.

Kaprekar proved that if we start with some four-digit number , in which not all the digits are equal, and successively apply this operation to it (calculate K(x), K(K(x)), ...), then sooner or later the number will appear. For this number the equality K(6174) = 7641 - 1467 = 6174 is true, therefore, the process on it will be cycled.

Your task is to write a program that calculates by the number .

Input

One integer x~(1 \le x \le 10^9) without leading zeroes.

Output

Print .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading