program pil_11_36(input,output);
const
  k = 6;
type
  str = packed array [1..k] of char;
var
  prev, cur, next : str;    
  separator : char;
{ flag : boolean}  

procedure readword(var w : str);
var           
  c : char;
  i : 1..k;
begin          
  for i:=1 to k do w[i] := ' ';
  read(c);
  i := 1;
  while (c<>'.')and(c<>',') do begin
    w[i] := c;
    i := i+1;
    read(c)
  end;
  separator := c;
end;

{returned TRUE if it is a last word}
{and FALSE if it is not            }
function readwordf(var w : str):boolean;
var           
  c : char;
  i : 1..k;
begin          
  for i:=1 to k do w[i] := ' ';
  read(c);
  i := 1;
  while (c<>'.')and(c<>',') do begin
    w[i] := c;
    i := i+1;
    read(c)
  end;
  readwordf := c='.';
end;

begin
  readword(prev);
  readword(cur);
  readword(next);
  if prev=next then Write(cur,';');
  while separator=',' do begin
    prev := cur;
    cur := next;
    readword(next);
    if prev=next then Write(cur,';');
  end;
{or this program should be like this,  }
{if the readword - is not the procedure}
{but a function readwordf:             }
{ readword(prev);                      }
{ readword(cur);                       }
{ b := readword(next);                 }
{ if prev=next then Write(cur,';');    }
{ while b do begin                     }
{   prev := cur;                       }
{   cur := next;                       }
{   b := readword(next);               }
{   if prev=next then Write(cur,';');  }
{ end;                                 }
end.
