a, b = input(), input()
c= []
for i in range(len(a)+1):
for j in range(i, len(a)+1):
if a[i:(j+1)] in b:
c.append(len(a[i:(j+1)]))
print(max(c))
a, b = input(), input()
c= []
for i in range(len(a)+1):
for j in range(i, len(a)+1):
if a[i:(j+1)] in b:
c.append(len(a[i:(j+1)]))
print(max(c))