program pil_10_16_e(input,output);
const
	n = 30;
  k = 5;
type
	str = packed array [1..k] of char;
var
	mas : array [1..n] of str;
  cur : str;
  counts : array [1..n] of integer;
  count : integer;
  i, j, l, WordCount : integer;
  c : char;
  f : boolean;
begin
  i := 1;
	repeat
  	read(c);
		j := 1;
    while (c<>',')and(c<>'.') do begin
    	mas[i][j] := c;
      j := j+1;
      read(c);
    end;
    i := i+1;
  until c='.';
  WordCount := i-1;

  counts[1] := 1;
  for i:=2 to WordCount do begin
  	cur := mas[i];
  	j:=i-1;
  	f := true;
    while (j>0) and f do begin 
    	j:=j-1;
    	if mas[j]=cur then f:=false;
    end;
    if j=0 then counts[i] := 1
    else begin
    	count := counts[j]+1;
      counts[i] := count;
      l := count-1;
      while l>0 do begin
				while mas[j]<>cur do j:=j-1;
        counts[j] := count;
        l := l-1;
        j:=j-1;
      end;
    end;
  end;
  for i:=1 to WordCount do begin
  	j:=i-1;
    cur := mas[i];
    while (j>0) and (mas[j]<>cur) do j:=j-1;
    if j=0 then
    	if counts[i]=1 then WriteLn(mas[i], ' - ', counts[i], ' time.')
      else WriteLn(mas[i], ' - ', counts[i], ' times.');
  end;
end.