# 不bp建表格了,我甜蜜直接暴力解
d=input()
c=input()
if len(d)>len(c):
d,c=c,d# python特有的交换方法
max_lenth=0
for wz in range(len(d)):
for wy in range(wz,len(d)):
if d[wz:wy+1] in c and len(d[wz:wy+1])>max_lenth:
max_lenth=len(d[wz:wy+1])
print(max_lenth)
d=input()
c=input()
if len(d)>len(c):
d,c=c,d# python特有的交换方法
max_lenth=0
for wz in range(len(d)):
for wy in range(wz,len(d)):
if d[wz:wy+1] in c and len(d[wz:wy+1])>max_lenth:
max_lenth=len(d[wz:wy+1])
print(max_lenth)