g (x:s) l =(if elem x l then[x] else [])++(if null s then [] else g s [k|k<-l,k/=x])
f s n k = if length s <=n then k else f s (n+1) (max k (length(g(take n s)(drop n s))))
main=do
 x<-getLine
 s<-getLine
 print$f s 1 0