Determine whether a number is nearly lucky: it contains only the digits 4 and 7, and the count of its lucky digits is itself lucky.
A positive integer is called lucky if every digit in its decimal representation is either 4 or 7.
A number is called nearly lucky if the number of lucky digits it contains is itself a lucky number.
Given an integer, decide whether it is nearly lucky.
4 and 7 in the number.4 and 7).YES if is nearly lucky, otherwise print NO.Example 1
Input
40047
Output
NO
Explanation
The digits 4 and 7 appear 3 times. Since 3 is not a lucky number, the answer is NO.
Example 2
Input
7744
Output
YES
Explanation
There are 4 lucky digits, and 4 is itself a lucky number, so the answer is YES.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.