let id x = x
let str = Scanf.scanf "%s\n" id

let n = String.length str
  
let array = Array.init n (fun n -> str.[n])
let list = Array.to_list array

let check l =
  let hd = List.hd l in
  List.for_all (fun x -> x = hd) l 
  
let rec make_alphalist n l =
  if n = 123 then l else make_alphalist (n+1) (char_of_int n :: l)

let rec subst c l =
  match l with
  | [a] -> []
  | a :: b :: rest ->
     if a=c || b=c then c :: subst c (b::rest) else a :: subst c (b::rest)
    
let rec count c n l =
  if check l then n else count c (n+1) (subst c l)

let rec make_cntlist alist cntlist =
  match alist with
  | [] -> cntlist
  | hd :: rest -> make_cntlist rest ((count hd 0 list) :: cntlist)

let alphalist = make_alphalist 97 []
let cntlist = List.sort compare (make_cntlist alphalist [])

let ans = List.hd cntlist

let () =
  Printf.printf "%d\n" ans