def print_common_strlen(str_short, str_long):
max_com_len = 0
compare_str = ''
i = 0
while i + max_com_len < len(str_short):
#判断目前最大公共子串长度加1是否公共子串
compare_str = str_short[i:i + max_com_len + 1]
#找不到就从下一个字符开始找
if compare_str not in str_long:
compare_str = ''
i += 1
continue
else:
#如果找到了,就是长度加1
max_com_len += 1
print(max_com_len)
str_one = input()
str_two = input()
if len(str_one) < len(str_two):
print_common_strlen(str_one, str_two)
else:
print_common_strlen(str_two, str_one)