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:
def check(s):
	cap_c=0
	small_c=0
	cap=['Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M']
	small=['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']
	for i in s:
		#print i
		if i in cap:
			cap_c+=1
		elif i in small:
			small_c+=1
	if cap_c==0 and small_c==0:
		return 'Invalid Input'
	else:
		return min(cap_c,small_c)
	return 0
try:
	t=int(raw_input())
	if t>10 or t<1:
		print 'Invalid Test'
	else:
		for i in xrange(t):
			inp=raw_input()
			if ' ' in inp:
				print 'Invalid Input'
			elif len(inp)>100 or len(inp)<1:
				print 'Invalid Input'
			else:
				print check(inp)
except:
	print 'Invalid Test'