LogiQuest

152. Happy Number

EasyCycle Detection

Replace n by the sum of the squares of its digits repeatedly. If it reaches 1, n is happy; otherwise it loops forever. Print YES or NO.

Input format

A single integer n.

Output format

YES or NO

Example 1

Input

19

Output

YES

Example 2

Input

2

Output

NO

Constraints

1 ≤ n ≤ 10⁹

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…