

The first line of input contains an integer ‘T’, representing the number of test cases.
The first line of each test case contains a string ‘STR’, representing the password.
For each test case, print a single integer, representing the number of changes we need to make.
Output for each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= |STR| <= 5000
Where |STR| is the length of the given string ‘STR’.
Time Limit : 1 sec
The idea is to check for all the conditions greedily. We need to check whether the password consists of at least one lowercase letter, one uppercase, and one digit and no repeated characters of length more than 2. There are 3 possible combinations, i.e., ‘N’ < 6, ‘N’ <= 20 and ‘N’ > 20.
For ‘N’ < 6 , we can insert the missing conditions.
For ‘N’ <= 20, we can replace the necessary characters.
For ‘N’ > 20, we can do combinations of deletions and replacements.
Example:
bbbbbb: In this, we can delete the last character and do 1 replacement.
bbbbbbb: In this, we can do 2 deletions to save 1 replacement.
bbbbbbbb: In this, we can do 3 deletions to save 1 replacement.
Here is the algorithm :