#(公共子串)ggzc[i][j]表示以str1[i-1]和str2[j-1]结尾的最近的公共子串的长度
def ggzc(str1,str2):
len1, len2, maxx = len(str1) + 1, len(str2) + 1, 0
juzheng = [[0 for j in range(len2)] for i in range(len1)]
for i in range(1, len1):
for j in range(1, len2):
if str1[i-1] == str2[j-1]:
juzheng[i][j] = juzheng[i-1][j-1] + 1
if juzheng[i][j] > maxx:
maxx = juzheng[i][j]
else:
juzheng[i][j] = 0
return maxx
print(ggzc(input(), input()))