var
  str1: array of string;
  str2: array of string := (',', ' ', '.', #13);
  chr1: char;
  i: integer;

begin
  readln(chr1);
  str1 := System.IO.File.ReadAllText('in.txt').Split(str2, System.StringSplitOptions.RemoveEmptyEntries);
  foreach str: string in str1 do
    if (str[1] = chr1) then
      System.IO.File.AppendAllText('out.txt', str + ' ');
end.