var s:string; min:byte; c:char; t:text;
begin
assign(t,'c:\file.txt');
reset(t);
min:=255;
repeat
read(t,c);
s:='';
while (c<>',') and (c<>'.') and (not eoln(t)) do
begin
s:=s+c;
read(t,c);
end;
if eoln(t) then readln(t);
if length(s)<min then min:=length(s);
until c='.';
close(t);
reset(t);
repeat
read(t,c);
s:='';
while (c<>',') and (c<>'.') do
begin
s:=s+c;
read(t,c);
end;
if eoln(t) then readln(t);
if length(s)=min then write(s,' ');
until c='.';
close(t);
end.