Uses crt;
var s1,s2: string;
x,y:integer;
function pos(s1,s2:string):integer;
begin
for x:=length(s1) downto 1 do
for y:=length(s2)downto 1 do
if (s1[x]=s2[y]) then pos:=x;
end;
begin
write('s1: '); readln(s1);
write('s2: '); readln(s2);
writeln(pos(s1,s2));
end.