let () =
  let s = read_line () in
  let rec shrink a ss c =
    let sl = String.length ss in
    if  sl = 1 || (ss = String.make sl c) then a
    else
      let ns = String.init (sl - 1) (fun i -> if ss.[i] = c || ss.[i+1] = c then c else ss.[i]) in
      shrink (a+1) ns c in
  let tbl = ['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z'] in
  List.map (shrink 0 s) tbl |> List.sort compare |> List.hd |> string_of_int |> print_endline

