406088: GYM102263 J Thanos Power
Description
After gathering all the infinity stones and dusting half the population of the universe, Thanos went to gardens street. He decided to plant some flowers using the reality stone.
So Thanos now wants to plant $$$N$$$ flowers in least number of steps needed. In each step he can: Choose a number $$$(0 \leq x)$$$,then Plant $$$10^x$$$ plants or remove $$$10^x$$$ plants with the help of the power stone. What is the least number of steps he needs to plant exactly $$$N$$$ flowers.
InputA single integer $$$N$$$ $$$(0 \le N \le 10^{10^5})$$$, the number of flowers Thanos wants to plant.
OutputThe least number of steps Thanos needs to plant $$$N$$$ plants.
ExamplesInput3000Output
3Input
231Output
6Note
In the first sample, fastest way to plant 3000 plants is:
step 1 plant $$$10^3$$$
step 2 plant $$$10^3$$$
step 3 plant $$$10^3$$$
so the answer is 3 steps.