let () = Scanf.scanf "%d" @@ fun n ->
  let s = read_line () in
  Array.init (n + 1) (fun i ->
    Array.init 26 (fun c -> Char.chr @@ Char.code 'a' + c)
    |> Array.to_list
    |> List.filter (fun c ->
        List.exists (fun i -> s.[i] = c) (Array.to_list @@ Array.init i @@ fun j -> j) && List.exists (fun i -> s.[i] = c) (Array.to_list @@ Array.init (n - i) (( + ) i)))
    |> List.length)
  |> Array.fold_left max min_int
  |> Printf.printf "%d\n"
