program alg_nudelman_vunsh; var s1,s2 : string; a : array[0..250,0..250]of byte; i,j : integer; vs : string; kol : longint; function Max(a,b : integer) : integer; begin if a > b then Max :=a else Max := b; end; procedure outAll(ii,jj : integer); var i,j : integer; { bol : boolean;} k : integer; begin if a[ii,jj] = 0 then begin inc(kol); writeln(vs); exit; end; i := ii;j := jj; while (a[i,j] = a[i - 1,j]) do dec(i); while (a[i,j] = a[i,j - 1]) do dec(j); { bol := i < ii;} k := i - j; vs := s1[i] + vs; outAll(i - 1,j - 1); delete(vs,1,1); i := ii;j := jj; while (a[i,j] = a[i,j - 1]) do dec(j); while (a[i,j] = a[i - 1,j]) do dec(i); if (j < jj) and (i - j <> k){ and (bol)} then begin vs := s2[j] + vs; outAll(i - 1,j - 1); delete(vs,1,1); end; end; begin readln(s1); readln(s2); for i := 0 to length(s1) do a[i,0] := 0; for i := 0 to length(s2) do a[0,i] := 0; for i := 1 to Length(s1) do for j := 1 to length(s2) do begin a[i,j] := Max(a[i-1,j],a[i,j-1]); if s1[i] = s2[j] then a[i,j] := Max(a[i,j],a[i-1,j-1] + 1); end; writeln(a[Length(s1),Length(s2)]); vs := ''; kol := 0; outAll(Length(s1),Length(s2)); writeln(kol); end.