Темы:
Other
More than anything, Pasha loves two things — music and order. Every day, when Pasha returns home, he turns on his laptop, goes to his page on the blue social network and listens to the songs added to his audio recording. The most difficult — choose which song to start listening to music today.
Of course, Pasha could choose the opening song somehow at random, guided by today's mood and current preferences in music. But there is no order in this. Therefore, Pasha came up with a clear scheme for choosing the starting song.
A long time ago, when Pasha once again suffered from a lack of order in the world around him, he promised himself that in his audio recordings there would always be such a number of songs N that the numbers in N did not repeat and there was no 0 among them. Such a number seemed to him practically perfect.
It was from this almost ideal number that Pasha decided to proceed when choosing the initial song. The selection scheme looks like this: first, Pasha looks at the number of songs in his audio recordings N. In this number, he swaps the numbers, sorting them in ascending order. So he gets the perfect number. Then he multiplies this ideal number by his favorite number 9. Here he could have stopped, but sometimes this work turns out to be too large, so Pasha takes the sum of the digits of the work as the number of the initial song.
Based on the number of songs in Pasha's recordings, print the number of the initial song for today.
Input
Given a natural number N. It is guaranteed that there is no digit 0 among the digits of N. All digits of N are different.
Imprint
Print a single number — desired number of the starting song.
Examples
|