First, you count lucky digits by extracting from right to left. You get 7 (lucky, count becomes 1), then 4 (lucky, count becomes 2), then 0 (not lucky, skip), then 0 (skip again), then 4 (lucky, count becomes 3).
After processing all digits, count is 3. Now check if 3 is lucky. You extract digits from 3, getting just the digit 3. Since 3 is neither 4 nor 7, it's not lucky. The original number had 3 lucky digits total, but 3 itself isn't a lucky number.
For 7747774, you count the digits: four 7s and three 4s gives total count 7. Now check if 7 is lucky. Extract the digit 7, which is either 4 or 7, so yes.