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

test=int(raw_input())
for i in range(0,test):
	try:
		a=raw_input()
	except:
		print 0
		continue
	try:
	    b=raw_input()
	except:
		print 0
		continue
	j,count=0,0
	length=len(a)
	lengthb=len(b)
	if length <=lengthb:
		k=length
	else:
		k=lengthb
	while j < k :
		if a[j]==b[j]:
			count+=1
		j+=1
	print count