module String = struct include String let fold_left f init str = let n = String.length str - 1 in let rec doit i acc = if i > n then acc else doit (i + 1) (f acc str.[i]) in doit 0 init end let min (x : int) y = if x < y then x else y let () = let s = read_line () in let doit cnt (t, r, e) = min t (min r (e / 2)) in String.fold_left (fun (t, r, e) c -> if c = 't' then t + 1, r, e else if c = 'r' then t, r + 1, e else if c = 'e' then t, r, e + 1 else t, r, e) (0, 0, 0) s |> doit 0 |> Printf.printf "%d\n"