n=io.read("*n","*l")
s=io.read()

t={}
for i=1,n do
    alphabet=s:sub(i,i)
    if not t[alphabet] then
        t[alphabet]={}
    end
    table.insert(t[alphabet],i)
end

max=0
for i=1,n do
    counter=0
    for alphabet,_ in pairs(t) do
        if #t[alphabet]>1 then
            if t[alphabet][1]<=i and i<=t[alphabet][#t[alphabet]] then
                counter=counter+1
            end
        end
    end
    max=math.max(counter,max)
end
print(max)