LearnPy Hub
← Loops problems
Hard

Happy Number

Replace a number by the sum of the squares of its digits, again and again. If you reach 1 the number is happy; if it loops forever it isn't. Read n and print happy or unhappy, then the number of steps taken to reach 1 or to repeat a number already seen.

Input

One integer n ≥ 1.

Output

Two lines.

Sample 1

Input
19
Output
happy
4

Sample 2

Input
1
Output
happy
0
solution.py
Output appears here
Happy Number · Python practice problem · LearnPy Hub