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

# Program using itertools.izip, possible alternatives
# itertools.izip_longest
# zip

import itertools

T = int(raw_input())

while T > 0:
	try:
		A = raw_input()
	except:
		print 0
		T -= 1
		continue
	
	try:
		B = raw_input()
	except:
		print 0
		T -= 1
		continue

	count = 0

	# itertools.izip returns iterator of tuple
	for a, b in itertools.izip(A, B):
		if a == b:
			count += 1

	print count

	T -= 1