program echo(input,output);
var
st1,st2,st:string;
a,b:array[1..80]of char;
i,j,k,max:integer;
function check(l:integer):boolean;
var i:integer;
begin
for i:=1 to l do
if a[i]<>b[i] then exit(false);
exit(true);
end;
begin
assign(input,'echo.in');assign(output,'echo.out');
reset(input);rewrite(output);
readln(st1);readln(st2);
if length(st1)>length(st2) then k:=length(st2) else k:=length(st1);
max:=0;
for i:=1 to k do begin
st:=copy(st1,1,i);
for j:=1 to i do a[j]:=st[j];
st:=copy(st2,length(st2)-i+1,i);
for j:=1 to i do b[j]:=st[j];
if check(i) then if i>max then max:=i;
st:=copy(st2,1,i);
for j:=1 to i do a[j]:=st[j];
st:=copy(st1,length(st1)-i+1,i);
for j:=1 to i do b[j]:=st[j];
if check(i) then if i>max then max:=i;
end;
writeln(max);
close(input);close(output);
end.