import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s1 = in.next();
String s2 = in.next();
boolean flag = s1.length()<=s2.length();
String str1;
String str2;
if(flag){
str1 = s1;
str2 = s2;
}else{
str1 = s2;
str2 = s1;
}
outer:
for(int i = str1.length(); i>0; i--){
for(int j = 0; j<str1.length(); j++){
if(j+i<=str1.length()){
if(str2.contains(str1.substring(j,j+i))){
System.out.print(i);
flag = false;
break outer;
}
}
}
}
if(flag){
System.out.print(0);
}
}
}