5
OIL
PFJMFWXRQYXBNJNTWIZVSRJIKPGIWEWN
UCWHELOLFDGGPYKMZ
CGHEAXJAMRSMDDNOJEFAOFVPAIVNSGJG
ZLOGAPUZTOHKFQGKSRSNFYVVQTIQMRJBSVOY
J
FYLI
WFSKQDNKTRHXZJC
COOGCEZEXKOZZQMKLLTTIL
0
0
0
0
0

for _ in xrange(input()):
	try:
		a=list(raw_input())
		b=list(raw_input())
	except EOFError:
		b=['!']
		a=['^']
		
	lena=len(a)
	lenb=len(b)
	if lena>lenb:
		while lenb<=lena:
			b.append('@')
			lenb=lenb+1
	elif lenb>lena:
		while lena<=lenb:
			a.append('$')
			lena=lena+1
	d=[ord(i)-ord(j) for i,j in zip(a,b)]
	count=0
	for x in d:
		if x==0:
			count=count+1
	print count