import Data.Array

exist_pos::Array Int Char -> [(Char,Maybe (Int,Int))]
exist_pos ar = let (f,l) = bounds ar in
                [(c,let ls = [i |i<-[f..l],(ar!i)==c] in if ls == [] then Nothing else Just(minimum ls,maximum ls))|c<-['a'..'z']]

make_ar::(Int,Int)->[(Char,Maybe (Int,Int))]->[Int]
make_ar (f,l) ls  = [length (filter (cond i) ls)|i<-[f..l]]
                  where cond i (_,v) = case v of
                                  Nothing    -> False
                                  Just (s,e) ->  (s <= i)&&(i < e)

solver::Array Int Char -> Int
solver ar = let (f,l) = bounds ar in
            let ls = exist_pos ar in
            let val = make_ar (f-1,l) ls in
            maximum val

main::IO()
main=do
  _<-getLine
  st<-getLine
  let ar = listArray (1,length st) st
  print (solver ar)