In this problem the only thing you should notice is that the only operation that you need to use is the changing of digits.
Indeed, adding leading digit operation worsens our situation - it gives nothing good.
On the other hand, incrementing number by 1 is equivalent to changing of last digit except the case when the last digit is 9. If N has k trailing nines and d < 9 is the next digit after nines then the block d 9 9 … 9 9 will be changed to (d+1) 0 0 … 0 0. So it is equivalent to changing of digit d and some useless changes from 9 to 0 that do not involve lucky digits. So we can use just one change of digit instead of this incrementing operation with the same effect in sense of lucky digits.
After noticing this, we see that the answer to the problem is simply the number of unlucky digits of N.
This is incorrect.
Suppose N = 539, add leading digit operation gives 544, then change 5 to 4 => total number of operations is 2 while number of unlucky digits is 3.
I think u havenot got the point adding 1 to 539 means total of operations as 1 add + change of two digits on adding and further we have to change units place afterwards…