Scanf.scanf "%s" (fun s -> let n = String.length s in let rec loop_i i acc = let rec loop_j j acc = let rec loop_k k acc = if k >= n then acc else let acc = if s.[k] = 'w' then min acc (k - i + 1) else acc in loop_k (k + 1) acc in if j >= n then acc else if s.[j] = 'w' then loop_j (j + 1) (loop_k (j + 1) acc) else loop_j (j + 1) acc in if i >= n then acc else if s.[i] = 'c' then loop_i (i + 1) (loop_j (i + 1) acc) else loop_i (i + 1) acc in let ans = loop_i 0 max_int in let ans = if ans = max_int then -1 else ans in Printf.printf "%d\n" ans )