Program zadatak_4;
uses StrUtils;
type slovo = record
    broj : integer;
    a : char;
    pozicija : smallint;
    end;
var k : array[1..10] of slovo;
    p : array[1..200000] of char;
    s : string;
    br, u, min, m, i : integer;
    c : boolean;
begin
    m := 0;
    c := false;
    br := 0;
    u := 1;
    readln(p);
    readln(s);
    for i := 1 to length(s) do begin
        k[i].a := s[i];
        k[i].broj := 0;
    end;
    repeat
        inc(br);
        if p[br] = k[u].a then begin
            repeat
                inc(k[u].broj);
                k[u].pozicija := br;
                inc(br);
            until ord(p[br]) <> ord(k[u].a);
            if u = length(s) then
                c := true;
            inc(u);
            dec(br);
        end;
        if c then begin
            u := 1;
            min := k[1].broj;
            for i := 2 to length(s) do begin
                if k[i].broj < min then
                    min := k[i].broj;
                k[i].broj := 0;
            end;
            m := m + min;
            for i := 1 to min do
                p[k[i].pozicija - i + 1] := '*';
            c := false;
        end;
    until ord(p[br]) = ord(' ');
    writeln(m);
    writeln(p);
end.