Problem: Marut loves good strings. According to him, good strings are those which contain either all alphabets of uppercase or lowercase.
While he is preparing for his exams, he finds many bad strings in his book and wants to convert them to good strings.
But he wants to do this in minimum number of operations.
 In one operation, he can pick only one character of any case and convert it 
to any other case.

As his exams are going on, he wants your help.

Input:
The first line contains an integer T, denoting the number of test cases.
Each test case consists of only one line with a string S which contains uppercase and lowercase alphabets..

Output:
Print the minimum number of operations, in which Marut can obtain a good string.
Print the answer for each test case in new line.

Constraints:
1 ≤ T ≤ 10
If T is not in this range, print "Invalid Test" (without the quotes)
1 ≤ Length of S ≤ 100
S can contain numbers, special characters but no spaces.
If the length of string is not in the above range or it does not contain any alphabets, print "Invalid Input" (without the quotes)  

For Example, if the input is:
0
TestString  

Print "Invalid Test" (without the quotes)

SAMPLE INPUT
3
abcEfg
!@6#2
123A

SAMPLE OUTPUT
1
Invalid Input
0

Solution (in PYTHON):

Solution:
import sys
 
small = 'abcdefghijklmnopqrstuvwxyz'
caps = small.upper()
 
def main():
	countLine = 0
	noTestCases = 0
	file_brk = sys.stdin.readlines()
	noActualTestCase = len(file_brk) -1
	for line in file_brk:
		line = line.rstrip('\n')
		if countLine==0:
			countLine+=1
			if not line.isdigit():
				print 'Invalid Test'
				break
			else:
				noTestCases = int(line)
				if noTestCases<1 or noTestCases>10:
					print 'Invalid Test'
					break
		else:
			countLine+=1
			if countLine>noTestCases+1:
				break
			print doStringThing(line)
 
def doStringThing(lineVal):
	noOfUpper = 0
	noOfLower = 0
	noLetters = True
	if not lineVal or len(lineVal)>100 or ' ' in lineVal:
		return 'Invalid Input'
	else:
		for letter in lineVal:
			if letter in small:
				noOfLower+=1
				noLetters = False
			elif letter in caps:
				noOfUpper+=1
				noLetters = False
	if noLetters:
		return 'Invalid Input'
	elif noOfUpper>noOfLower:
		return str(noOfLower)
	else:
		return str(noOfUpper)
 
 
 
if __name__ == '__main__':
	main()