#P318. 练54.1 6084问题

练54.1 6084问题

Description

Given any four-digit number, rearrange its digits to form the largest and smallest possible four-digit numbers, and calculate the difference between them.
For example: For the number 37213721, you can form 73217321 and 12371237, and the difference is 732112377321−1237.

Input Format

A four-digit number.

Output Format

The difference as described in the problem.

Sample

3721
6084