CodeLab Academy 📞 9936 6696
← List Python · Level 9: Functions and dicts Code · 90 points ← #846 #848 →

#847. Kaprekar steps

You get a 4-digit number whose digits are not all the same. Sort its digits from biggest to smallest to make one number and from smallest to biggest to make another, then subtract the second from the first. How many times must you do this to reach 6174? (Always treat the number as 4 digits, adding 0s in front.) ### Input One integer n (1000 ≤ n ≤ 9999). ### Output Answer.

Examples

Input
6722
Output
5
Input
7237
Output
5

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!