Here's your approach:
Read the number as a long integer.
Initialize a counter to 0.
Loop while the number is greater than 0.
Get the last digit using modulo 10.
If the digit is 4 or 7, increment the counter.
Divide the number by 10 to remove the last digit.
After the loop, check if the counter is a lucky number by verifying all its digits are 4 or 7.
Output YES if the counter is lucky, NO otherwise. You need to handle the special case where the counter is 0 (no lucky digits found), which is not a lucky number.