let () = let rec charlist_of_string str n i = if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in let rec search lst target = match lst with | [] -> raise Not_found | h :: t -> if h = target then t else h :: search t target in Scanf.scanf "%s\n" @@ fun s -> let lst = ref (charlist_of_string s (String.length s) 0) in let flag = ref true in let ans = ref 0 in while !flag do try let l = search !lst 't' in let l = search l 'r' in let l = search l 'e' in let l = search l 'e' in lst := l; ans := !ans + 1 with Not_found -> flag := false done; Printf.printf "%d\n" !ans