s = input()
t = input()

if len(s) > len(t):
    s, t = t, s

# Initialize an empty list that stores the matching substring 
# between s and t:
mat_subs = []

# Use the classic nested for loop to create substrings of s:
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        sub = s[i:j]
        if sub in t:
            mat_subs.append(sub)

## Use a list comprehension to find the length of the longest
# matching substring.
# Remember to consider the case where there is not matching substring.
if mat_subs:
    print(max([len(sub) for sub in mat_subs]))
else:
    print(0)