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

t = int(raw_input())
while t>0:
	try:
		aa = raw_input()
		bb = raw_input()
   		print(sum(a==b for a, b in zip(aa, bb)))
   	except:
   		print(0)
   	
   	t = t-1