Grandma's Whims (a task from the sponsor)
When our heroes had already boarded the plane, they noticed an eccentric young man who kept scratching his head and jotting down some incomprehensible words like include, for, and void in his notebook. After introducing themselves, Kotyhoroshko and his friends discovered that his name was Semen, a programmer at NIX Solutions. Due to his excellent work, he received a substantial bonus, which he used for a vacation on exotic islands. With the remaining money, he plans to buy a car. However, there's a small issue—his grandmother, an expert in numerology, insists that the car number must be "lucky" to ensure Semen avoids police stops and enjoys good fortune. To determine if a number is "lucky," she performs the following calculations:
She calculates the sum of the squares of the digits of the number. She then repeats this operation on the resulting number and continues until the result is either one or the calculations enter an infinite loop. If the process ends with one, the number is considered lucky.
Semen finds doing these calculations by hand tedious, so he wrote a program to determine if a car number is "lucky." Can you write such a program too?
The car number consists of five digits.
Input
The car number N (10000 ≤ N ≤ 99999) is provided in a single line of the input file.
Output
Output the word HAPPY if the number is lucky, and SAD if it is not.