import sys
while True:
a = sys.stdin.readline().strip()
if a == '':
break
b = sys.stdin.readline().strip()
m = len(a)
n = len(b)
counter = [[0]*(n+1) for x in range(m+1)]
# (m+1)个列表,每个列表含有(n+1)个元素
longest = 0
lcs_set = set() # 创建无顺序不重复的元素集
for i in range(1, m+1):
for j in range(1, n+1):
if a[i-1] == b[j-1]:
c = counter[i-1][j-1] + 1
counter[i][j] = c
if c > longest:
longest = c
lcs_set.add(a[i-c:i])
elif c == longest:
lcs_set.add(a[i-c:i])
max = 0
for i in lcs_set:
if len(i) > max :
max = len(i)
print(max)