The core idea is splitting the problem into two parts. First, count how many 4s and 7s appear. Second, check if that count is a lucky number (contains only 4s and 7s). Both parts use digit extraction.
I'll show you the digit extraction pattern. Use modulo 10 to get the last digit, check if it's 4 or 7, then divide by 10 to remove it. Repeat until the number becomes 0. This gives the count of lucky digits.
For the second part, check if the count itself is lucky. Apply the same extraction, but verify that every digit is 4 or 7. If you find any other digit, the count isn't lucky.