In the world of magic there exist a gate to travel in time. Magical authority has appointed Alice to keep a record of all the people passing through that gate. Every time a person goes inside that gate Alice writes an ‘I’ in a paper and every time a person comes out of the gate Alice writes down ‘O’. Once, magical authority asked Alice about the number of peoples who have used that gate. Now looking at ‘I’ and ‘O’ at his paper it’s impossible to tell the exact number of peoples who have used that gate but he’s sure that there exist a method to know the minimum number of distinct peoples he could have seen passing through the gate. Can you write a code to know the minimum number of peoples he could have seen?
First line of input contains a number T i.e. the number of test cases. Each of the next T lines contains a string S which is the record Alice has kept in his diary.
Your code should print T lines each having one numbers, i.e. the minimum number of peoples he could have seen.
1<=T<=100 1<=length of S<=1000
2 IOIOI OOO