str1=input()
str2=input()
count_list=[]
i=0
j=0
while i < len(str1):
while j < len(str1):
j+=1
if str1[i:j] in str2:
count_list.append(j-i)
continue
else:
count_list.append(0)
break
i+=1
print(max(count_list))
str2=input()
count_list=[]
i=0
j=0
while i < len(str1):
while j < len(str1):
j+=1
if str1[i:j] in str2:
count_list.append(j-i)
continue
else:
count_list.append(0)
break
i+=1
print(max(count_list))