"""
Sameer Pai
Senior Division
Bergen County Academies
"""

def solve(s, t):
	lsub = ""
	for i in range(len(s)):
		for j in range(i, len(s)):
			if s[i:j+1] in t:
				if j - i + 1 > len(lsub):
					lsub = s[i:j+1]
				if j - i + 1 == len(lsub) and s[i:j+1] < lsub:
					lsub = s[i:j+1]
	ans = len(lsub)
	if ans == 0:
		return 0

	s1 = s[:s.find(lsub)]
	s2 = s[s.find(lsub) + len(lsub):]

	t1 = t[:t.find(lsub)]
	t2 = t[t.find(lsub) + len(lsub):]
	ans += solve(s1, t1)
	ans += solve(s2, t2)

	return ans

f = open("2sr_sampledata.txt", "r")
i=1
while True:
	s = f.readline().strip().upper()
	if not s:
		break
	sg = ""
	for c in s:
		if c.isalpha():
			sg += c

	t = f.readline().strip().upper()
	tg = ""
	for c in t:
		if c.isalpha():
			tg += c

	print(str(i)+".", solve(sg, tg))
	i+=1