Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.Let A be a set of positions in the string. Let's call it pretty if following conditions are met:  letters on positions from A in the string are all distinct and lowercase;  there are no uppercase letters in the string which are situated between positions from A (i.e. there is no such j that s[j] is an uppercase letter, and a1 < j < a2 for some a1 and a2 from A). Write a program that will determine the maximum number of elements in a pretty set of positions.

The first line contains a single integer n (1 ≤ n ≤ 200) — length of string s. The second line contains a string s consisting of lowercase and uppercase Latin letters.

Print maximum number of elements in pretty set of positions for string s.

NoteIn the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6 and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1 and 8 is not suitable because there is an uppercase letter 'B' between these position.In the second example desired positions can be 7, 8 and 11. There are other ways to choose pretty set consisting of three elements.In the third example the given string s does not contain any lowercase letters, so the answer is 0.

n = int(input())
s = input()
res = 0
Set = set()
for i in range(n):
    if 'A'<=s[i]<='Z':
        res=max(res,len(Set))
        Set.clear()
    else:
        Set.add(s[i])
print(max(res,len(Set)))

# cook your dish here
n=int(input())
string=str(input())
c=0
maxi=0
a=[]
i=0
while i < len(string):
    while(i<len(string) and ord(string[i])>=97 and ord(string[i])<=122):
        a.append(string[i])
        i+=1

    if len(list(set(a)))>maxi:
        maxi=len(list(set(a)))
    a=[]

    i+=1
print(maxi)

from sys import stdin
upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
s = set()
ans = 0
n = int(stdin.readline())
a = stdin.readline().strip()
for i in a:
 if i in upper:
  ans = max(ans,len(s))
  s = set()
 else:
  s.add(i)
ans = max(ans,len(s))
print ans

import re
input()
print max(map(len,map(set,re.split('[A-Z]',raw_input()))))

import re

n = int(input())
cute = input()
temp = str()

posl = [a for a in re.split(r'([A-Z][a-z]*)', cute)]

maxlen = 0
for i in range(len(posl)):
    posl[i] = ''.join([x[0] for x in zip(posl[i], posl[i].upper()) if x[0] != x[1]])
    posl[i] = ''.join(set(posl[i]))
    if len(posl[i]) > maxlen:
        maxlen = len(posl[i])

print(maxlen)

n=int(input())
s=input()
a=set()
m=0
for i in s:
    if i.islower():
        a.add(i)
        m=max(m,len(a))
    else:
        a.clear()
print(m)

n = int(input())
s = input()
k = []
ans = 0
for i in s:
    ans = max(len(k), ans)
    if i.islower():
        if not i in k:
            k.append(i)
    else:
        k = []
        tmp = 0
ans = max(len(k), ans)
print(ans)

from __future__ import print_function, division
from sys import stdin, stdout
from fractions import gcd
# from math import *
from collections import *
from operator import mul
from functools import reduce
from copy import copy

rstr = lambda: stdin.readline().strip()
rstrs = lambda: [str(x) for x in stdin.readline().split()]
rint = lambda: int(stdin.readline())
rints = lambda: [int(x) for x in stdin.readline().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
pr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\n')
out = []

n, s, ans = int(input()), rstr(), 0
dis = set()

for i in s:
    if i == i.upper():
        dis = set()
    else:
        dis.add(i)
    ans = max(ans, len(dis))

print(ans)

def solve():

    n = int(input())
    sentence = input()

    alpha = "abcdefghijklmnopqrstuvwxyz"
    alp = [[]]

    for st in sentence:
        if st in alpha:
            if st not in alp[-1]:
                alp[-1].append(st)
        else:
            alp.append([])

    #print(alp)
    return max([len(e) for e in alp])

print(solve())

#http://codeforces.com/problemset/problem/864/B
#solved

n = int(input())
array = input()
used = []
longest = 0

for i in array:
    if i.isupper():
        if len(used) > longest:
            longest = len(used)

        used = []

    else:
        if i not in used:
            used.append(i)

if len(used) > longest:
    longest = len(used)

print(longest)

n=int(input())
d=input()
setim=set()
for i in range(0,len(d)):
  f=True
  nset=set()
  for j in range(i,len(d)):
    if d[j].isupper():
      break
    nset.add(d[j])
  if len(nset)>len(setim):
    setim=nset
print(len(setim))

# O(nlogn)
def main():
  n = int(input())
  s = input()

  low_chars = set()
  max_power = 0
  for c in s:
    if c.isupper():
      max_power = max(max_power, len(low_chars))
      low_chars = set()
    else:
      low_chars.add(c)

  if len(low_chars) > 0:
    max_power = max(max_power, len(low_chars))

  print(max_power)

main()

n = int(input())
s = input()
s = s[:n+1]
li = []
ans = 0
for i in s:
    if i.islower():
        if i not in li:
            li.append(i)
            ans = max(ans, len(li))
    else:
        li.clear()
print(ans)

import re
n = input()
s = raw_input()
print max(map(lambda x: len(set(x)), re.split(r'[A-Z]', s)))

raw_input()
str = raw_input() + "A"
maxSize = 0
s = set()
for letter in str:
    if letter.isupper():
        maxSize = max(maxSize, len(s))
        s = set()
    else:
        s.add(letter)
print maxSize

n = int(input())
s = input()+"A"
l,r=0,0
ans = 0
while l<n+1:
	if s[l].isupper():
		ans = max(len(set(i for i in s[r:l])),ans)
		l+=1
		r=l
	else:
		l+=1

print(ans)

n=input()
s=raw_input()
l=[]
x=""
for i in range(n):
    if s[i].isupper():
        l.append(x)
        x=""
    else:
        x+=s[i]
l.append(x)
k=0
for j in l:
    k=max(k,len(set(j)))
print k

n = int(input())
line = input()

s = set()
l = -1
index = 0

while index < len(line):
	if line[index].lower() == line[index]:
		s.add(line[index])
	else:
		l = max(l, len(s))
		s.clear()
	index += 1

print(max(l, len(s)))

num = [int(x) for x in raw_input('').split(' ')][0]
word = raw_input('')
n = len(word)

max_size = 0
start = 0
while start < n:
    while start < n and word[start].lower() != word[start]:
        start += 1
    end = start
    distinct_chars = set([])
    while end < n and word[end].lower() == word[end]:
        if word[end] not in distinct_chars:
            distinct_chars.add(word[end])
        end += 1
    max_size = max(max_size, len(distinct_chars))
    start = end

print max_size

input()
s = input().translate(str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ', ' ' * 26)).split()
print(0 if s == [] else max([len(set(t)) for t in s]))

n = int(input())
s = input()
def rec(dp,s,i,j,k = set()):
    if(j==len(s) or i == len(s)):
        return 0
    if(dp[i][j] != -1):
        return dp[i][j]
    if(s[j].isupper()):
        dp[i][j] = 0
        return 0
    m1 = -1
    if(s[j] not in k):
        k.add(s[j])
        m1 = 1+rec(dp,s,i,j+1,k)
        k.remove(s[j])
    if(len(k) == 0): dp[i][j] = max(m1,rec(dp,s,i+1,j+1,k))
    else: dp[i][j] = max(m1,rec(dp,s,i,j+1,k))
    return dp[i][j]
dp = [[-1 for i in range(n)] for i in range(n)]
ans = 0
for i in range(len(s)):
    ans = max(ans,rec(dp,s,i,i))
print (ans)

import re,sys

l = int(input())
s = input()

if s.isupper():
    print(0)
    sys.exit()

#get consecutive lowercase substrings
ss = re.sub( r"([A-Z])", r" ", s).split()
print(max(len(i) for i in [set(i) for i in ss]))

n=int(input())
s=input()
sm=[-1]
count=[]
c=0
for i in s:

    if ord(i)<123 and ord(i)>96:
        #print(sm[::-1],sm[::-1].index(-1))
        if i not in sm[len(sm)-sm[::-1].index(-1):]:
            c+=1
            sm.append(i)
            count.append(c)

    else:
        sm.append(-1)
    if sm[-1]==-1:
        c=0
if len(count)>0:
    print(max(count))
else:
    print(0)

n=input()
a=raw_input()
b=[]
x=""
for i in range(n):
    #print a[i],a[i].isupper()
    if a[i].isupper():
        b.append(x)
        x=""
    else:
        x+=a[i]
b.append(x)
y=-1
for i in b:
    y=max(len(set(i)),y)
print y

n = int(raw_input())
s = raw_input()

lowercase = 'abcdefghijklmnopqrstuvwxyz'

cur = set()
ans = 0
for c in s:
    if c in lowercase:
        cur.add(c)
        ans = max(ans, len(cur))
    else:
        cur = set()

print ans

n = int(input())

s = input()
s+='A'

t = 0
mp = {}
ans = 0
for i in range(n+1):
    #print(mp)
    if s[i].islower():
        t+=1
        if s[i] not in mp:
            mp[s[i]]=1
    else:

        ans = max(ans,len(mp))
        t = 0
        mp = {}
print(ans)

n = int(input())
s = input()
myset = set()
ans = 0
for x in s:
  if x.islower():
    myset.add(x)
    ans = max(ans, len(myset))
  else:
    myset.clear()
print(ans)

n = int(input())
s = input()
best = 0
a = set()
for i in range(n):
	if s[i].islower():
		a.add(s[i])
	if s[i].isupper() or i==n-1:
		best = max(best , len(a))
		a = set()
print(best)

n = int(input())
t = input()
d = set({})
temp = []
count = 0
z = float("-inf")
for i in t:
	if ord(i) >= 97 and ord(i) <= 122:
		d.add(i)
	elif ord(i) >= 65 and ord(i) <= 90:
		z = max(z,len(d))
		d = set({})
z = max(z,len(d))
print(z)

def main():
    t=input()
    n=raw_input()
    n+="@"
    #print n
    if len(n)==2:
        if ord(n[0])<95:
            print 0
        else:
            print 1
    else:
        r=[]
        for i in xrange(t):
            if n[i]!=n[i+1]:
                r.append(n[i])
        if n[t-1]!=n[t]:
            r.append(n[t])
        k=[]
        p=[]
        #print r
        for i in r:
            #if i==r[len(r)-1] and ord(i)>95:
                #r.append("A")
                #print r
            if ord(i)>95:
                k.append(i)
            else:
                p.append(len(set(k)))
                k=[]
        print max(p)
if __name__ == '__main__':
    main()

n = int(input())
s = input()
l_upper = []
for i in range(len(s)):
    if s[i].isupper() == True:
        l_upper.append(i)

if len(l_upper) == 0 :
    print(len(set(s)))
elif len(l_upper) == 1:
    print(max(len(set(s[:l_upper[0]])), len(set(s[l_upper[0]: ])) - 1))
else:
    all_len = []
    all_len.append(len(set(s[0: l_upper[0]])))
    for i in range(len(l_upper)- 1):
        all_len.append(len(set(s[l_upper[i]: l_upper[i+1]])) -  1)
    all_len.append(len(set(s[l_upper[-1]: ])) - 1)
    print(max(all_len))

def max_sim(s):
    return len(set(s))

raw_input()

s = raw_input()

for c in xrange(ord('A'), ord('Z') + 1):
    s = s.replace(chr(c), '*')

print max(max_sim(ss) for ss in s.split('*'))

BIG_LETTERS = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','W','V','X','Y','Z')
SMALL_LETTERS = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','v','x','y','z')
n = int(input())
s = input()
max = 0
if s.isupper() == True:
    print(0)
elif s.islower() == True:
    st = ''
    for i in range(n):
        if s[i] not in st:
            st +=s[i]
    print(len(st))
else:
    st = ''
    for i in range(n):
        if s[i] in SMALL_LETTERS and s[i] not in st:
            st += s[i]
        elif s[i] in BIG_LETTERS:
            if len(st) > max:
                max = len(st)
            st = ''
    if len(st)>max:
        max = len(st)
    print(max)

N=int(input())
S=input()
j=0
D=[]
C=[]
for i in range(0,N):
  if(ord(S[i])>=ord('a') and ord(S[i])<=ord('z')):
    if(j==0):
      D=[]
      j=1
      if S[i] not in D:
        D.append(S[i])
    if(j==1):
      if S[i] not in D:
        D.append(S[i])
  elif(j==1):
    C.append(D[:])
    j=0
C.append(D[:])
if(len(C)!=0):
  D1=C[:]
  D1=list(map(len,D1))
  D2=D1.index(max(D1))
  print(D1[D2])
else:
  print(len(D))

n = input()
s = str(input())
a = set()
res = 0
for i in s:
    if i.islower():
        a.add(i)
        res = max(res,len(a))
    else:
        a.clear()
print(res)

n = input()
a = raw_input()
b1 = set()
b2 = 0
for i in xrange(n):
	if ord(a[i])<91:
		b2 = max(b2,len(b1))
		b1 = set()
	else:
		b1.add(a[i])
print max(b2,len(b1))

INF = 999999999999999999L
try:
    inFile = open("B.txt")
except:
    inFile = None

def read():
    if inFile:
        return inFile.readline().strip()
    else:
        return raw_input().strip()

def read_ints():
    return map(int,read().split())

n = int(read())
s = read()
ans = 0
i = 0
while i < len(s):
    if s[i].isupper():
        i += 1
        continue
    letters = set([])
    j = i
    while j < len(s) and s[j].islower():
        letters.add(s[j])
        j += 1
    #print i,j,letters
    ans = max(ans,len(letters))
    i = j
print ans

import re
input()
print(max(map(lambda w: len(set(w)), re.split('[A-Z]', input()))))

n=int(input())
s=input()
p=set()
l=0
for i in range(n):
    if s[i].isupper():
        if len(p)>l:
            l=len(p)
        p=set()
    else:
        p.add(s[i])
if len(p)>l:
    l=len(p)
print(l)

if __name__ =="__main__":
	l = int(input())
	s = input()
	sk = set()
	k = [0]
	l = 0
	mx = 0
	for i in s:
		if 65<=ord(i)<=90:
			k.append(len(sk))
			sk = set()
			l+=1
		else:
			sk.add(i)
		if len(sk)>mx:
			mx = len(sk)
	print(mx)

from string import ascii_lowercase
from string import ascii_uppercase

n=int(raw_input())
string=map (str, raw_input().strip())
maximo=0
setActual=set()

for i, item in enumerate (string):
	if item in ascii_lowercase:
		setActual.add(item)
	else:
		maximo=max (maximo, len (setActual))
		setActual=set()

print max (maximo, len (setActual))

input()
string = input()

prettySet = set()
count=0
for c in string:
    if c.islower():
        prettySet.add(c)
        count=max(count,len(prettySet))
    else:
        prettySet.clear()

print(count)

n = int(input())
s = input()
u = set()
cnt = 0
for i in range(n):
    if s[i].islower():
        u.add(s[i])
    elif s[i].isupper():
        cnt = max(len(u),cnt)
        u = set()
cnt = max(cnt,len(u))
print(cnt)

n = int(raw_input())
s = raw_input().strip()
ans = -1
t = ""
for i in range(n):
  x = s[i]
  if x.islower():
    t += x
    continue
  ans = max(ans, len(set(t)))
  t = ""
ans = max(ans, len(set(t)))
print ans

from sys import stdin,stderr,maxsize
mod = int(1e9)+7
def I(): return int(stdin.readline())
def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return input().strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
from collections import Counter,defaultdict
from itertools import permutations
import re
def bark():
    n = I();    s =S()
    a = re.split('[A-Z]+',s)
    p = max(map(lambda x: len(set(x)),a))
    return p
if __name__ == '__main__':
    print(bark())

n=int(input())
a=list(input())
c=[]
d=[]
b=[0]*(n+1)

for i in range(n):
    if ord('a') <= ord(a[i]) <= ord('z'):
        b[i]=ord(a[i])
    else:
        c.append(i)
try:
    for i in range(len(c) + 1):
        if i==0:
            d.append(len(set(b[:c[0]])))
        elif i==len(c):
            d.append(len(set(b[c[-1]:])) - 1)
        else:
            d.append(len(set(b[c[i-1] + 1:c[i]])))
    print(max(d))
except:print(len(set(a)))

n=input()
s=raw_input()
l=[]
c=0
ans=0
for i in range(n):
    if s[i]<='z' and s[i]>='a' and s[i] not in l :
        c+=1
        l.append(s[i])
        ans=max(ans,c)
    elif s[i]<='Z' and s[i]>='A':
        l=[]
        c=0
print ans

n=input()
a=raw_input()
s=set()
res=0

for b in a:
    if b.isupper():
        res=max(len(s),res)
        s.clear()
    else:
        s.add(b)
res=max(len(s),res)
print res

if __name__=="__main__":
    n=input()
    s=raw_input()
    mx=-1
    st=set()
    for i in s:
        if i.islower():
            st.add(i)
        else:
            st.clear()
        l=len(st)
        if l>mx:
            mx=l
    print mx

n = input()
s =  raw_input().strip()
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
k = ""
p = []
for i in s :
	if i not in l :
		#print i
		if i not in k :
			k += i
	else :
		p.append(len(k)*(-1))
		k = ""
p.append(len(k)*(-1))
p.sort()
print p[0]*(-1)

n=int(input())
s = input()
sm = set()
me=0
l=[]
for i in range(n):
    if s[i].islower():
        sm.add(s[i])
        if(me<len(sm)):
            me=len(sm)
            l.append(me)

    elif s[i].isupper():
        sm.clear()
        me=0
if(len(l)>0):
    print(max(l))
else:
    print(0)

n=int(input())
s=input()
sub=[]
ans=0
for a in range(0,n):
    letter=s[a]
    #print("letter",letter)
    if (letter not in sub) and letter.islower()==True:
        sub.append(letter)
        #print(sub)
    if letter.islower()==False or a==n-1:
        #print(sub)
        ans=max(ans,len(sub))
        sub=[]
        continue

print(ans)

n = input()
s = str(input())
a = set()
res = 0
for i in s:
    if i.islower():
        a.add(i)
        res = max(res,len(a))
    else:
        a.clear()
print(res)

n = input()
a = raw_input()
b1 = set()
b2 = 0
for i in xrange(n):
	if ord(a[i])<91:
		b2 = max(b2,len(b1))
		b1 = set()
	else:
		b1.add(a[i])
print max(b2,len(b1))

n=int(raw_input())
s= raw_input()

def prt(s):
    n=len(s)
    st=[]
    lt=0
    maxlt=0
    lc='qwertyuiopasdfghjklzxcvbnm'
    for x in s:
        if x in lc and x not in st:
            st.append(x)
            lt+=1
            maxlt=max(maxlt,lt)
        elif x not in lc:
            st=[]
            lt=0
    return maxlt

print prt(s)

def strp(string):
    sets = []
    s = set()
    for c in string:
        if c.isupper():
            if len(s):
                sets.append(s)
            s = set()
        else:
            s.add(c)
    if len(s):
        sets.append(s)

    return len(sets) and max(map(len,sets))

input()
string = input()
print(strp(string))

ans = 0
combo = set()
pre = -1
input()
for c in input():
  if c.isupper():
    ans = max(ans, len(combo))
    combo = set()
    pre = -1
  elif c != pre:
    combo.add(c)
    pre = c
print(max(ans, len(combo)))

n = int(input())
s = input()
l =[]
maxi = 0
for i in range(n):
    if s[i].isupper():
        maxi = max(maxi,len(set(l)))
        l=[]
    else:
        l.append(s[i])
maxi = max(maxi,len(set(l)))
print(maxi)

# May the Speedforce be with us...
'''
for _ in range(int(input())):
arr=list(map(int,input().split()))
n,k=map(int,input().split())
n=int(input())
s=input()

from collections import defaultdict
d=defaultdict()

d=dict()
s=set()
s.intersection()
s.union()
s.difference()

problem statement achhe se padhna hai
age se bhi dekhna hai, piche se bhi dekhna hai
'''
from math import gcd,ceil
from collections import defaultdict as dd
def lcm(a,b):
	return (a*b)//gcd(a,b)
def inin():
	return int(input())
def inar():
	return list(map(int,input().split()))
def ar(element,size):
	return [element for i in range(size)]
def digitsum(num):
	su=0
	while(num):
		su+=num%10
		num//=10
	return su

n=inin()
string=list(input())
arr=[]
ss=set()
for i in string:
	if i.isupper():
		arr.append(ss)
		ss=set()
	else:
		ss.add(i)
arr.append(ss)
ans=0
for i in arr:
	ans=max(ans,len(i))
print(ans)

input()
string = input()

prettySet = set()
count=0
for c in string:
    if c.islower():
        prettySet.add(c)
        count=max(count,len(prettySet))
    else:
        prettySet.clear()

print(count)

n = int(input())
s = input()
u = set()
cnt = 0
for i in range(n):
    if s[i].islower():
        u.add(s[i])
    elif s[i].isupper():
        cnt = max(len(u),cnt)
        u = set()
cnt = max(cnt,len(u))
print(cnt)

def isLowerCase(s):
    if s>='a' and s<='z':
        return True
    else:
        return False

n=int(input())
s=input().strip()
st=set()
flag=0
maxx=0
count=0
for i in range(n):
    if flag==0:
        if isLowerCase(s[i]):
            if s[i] not in st:
                count+=1
                st.add(s[i])
        else:
            flag=1
            if maxx<count:
                maxx=count
    else:
        if isLowerCase(s[i]):
            flag=0
            st=set([s[i]])
            count=1
if maxx<count:
    maxx=count
print(maxx)

import os
import sys
import re

if 'PYCHARM' in os.environ:
    sys.stdin = open('in', 'r')

def c(word):
    chs = set()
    for c in word:
        chs.add(c)
    return len(chs)

input()
print(max(map(c, re.split('[A-Z]', input()))))

from collections import Counter

N = input()
S = raw_input()
st = set()
ans = 0

for s in S:
    if s.isupper():
        ans = max(ans, len(st))
        st = set()
    else:
        st.add(s)

ans = max(ans, len(st))
print ans

n = int(input())
s = input()
s = s[:n+1]
li = []
ans = 0
for i in s:
    if i.islower():
        if i not in li:
            li.append(i)
            ans = max(ans, len(li))
    else:
        li.clear()
print(ans)

l = []
ans = 0
low = 'qwertyuiopasdfghjklzxcvbnm'

n = int(input())
s = input()
for c in s:
    if(c not in low):
        ans = max(ans, len(l))
        l.clear()
    elif(c not in l):
        l.append(c)
ans = max(ans, len(l))
print(ans)

def solve(a, n):
  b = [ord(c) - 96 for c in a]
  maxl = 0
  start = 0
  end = 1
  while True:
    while start < n and b[start] < 0:
      start += 1
    if start >= n:
      return maxl
    end = start + 1
    while end < n and b[end] > 0:
      end += 1
    l = len(set(b[start:end]))
    if l > maxl:
      maxl = l
    start = end

def main():
  n = input()
  a = raw_input()
  print solve(a, n)

main()

n = int(input())
s = input()
best = 0
a = set()
for i in range(n):
	if s[i].islower():
		a.add(s[i])
	if s[i].isupper() or i==n-1:
		best = max(best , len(a))
		a = set()
print(best)

lc = "abcdefghijklmnopqrstuvwxyz"
uc = "ABCDEFGHIJKLMNOPQRSTUVWQYZ"
n = int(input())
s = input()
st = ""
c = 0
l = []
for i in range (n):
	if (s[i] in lc):
		if s[i] not in st:
			st += s[i]
			c += 1
	else:
		l.append(c)
		st = ""
		c = 0
l.append(c)
print(max(l))

n = int(input())
s = str(input())
lis_cap = []
for i in range(len(s)):
    if (s[i]).isupper():
        lis_cap.append(i)
if not lis_cap or lis_cap[-1] != n-1:
    lis_cap.append(n)
lis_ans = []
start = 0
for i in lis_cap:
    end = i
    se = set([])
    for j in range(start,end):
        se.add(s[j])
    start = end+1
    lis_ans.append(len(se))
print (max(lis_ans))

s = input()
s = input()

def isupper(c):
	return 'A' <= c and c <='Z'

def islower(c):
	return 'a' <= c and c <='z'

def h(c):
	return ord(c) - ord('a')

answer = 0
waiting_lower = True

for i in range(len(s)):
	if islower(s[i]):
		if waiting_lower:
			count = 1
			waiting_lower = False
			appear = [True if _ == h(s[i])  else False for _ in range(26)]
		else:
			if not appear[h(s[i])]:
				count += 1
				appear[h(s[i])] = True

		answer = max(count,answer)
	else:
		waiting_lower = True

print(answer)

n = int(raw_input())
s = raw_input()
upper = [-1]
for i, ss in enumerate(s):
    if ord('A') <= ord(ss) <= ord('Z'):
        upper.append(i)
upper.append(len(s))
intervals = zip(upper[:-1], upper[1:])
print max(len(set(s[q+1: w])) for q, w in intervals)

n=int(input())
s=list(input())
b=[]
#print(s)
d=[]
j=0
for i in range(n):
    d.append([])
    if (ord(s[i]) in range(ord('a'),ord('z')+1)) and not(s[i] in d[j]):
        d[j].append(s[i])
    elif (ord(s[i]) in range(ord('A'),ord('Z')+1)):
        j+=1
        d.append([])
for i in d:
    b.append(len(i))
print(max(b))

def strp(string):
    sets = []
    s = set()
    for c in string:
        if c.isupper():
            if len(s):
                sets.append(s)
            s = set()
        else:
            s.add(c)
    if len(s):
        sets.append(s)

    return len(sets) and max(map(len,sets))

input()
string = input()
print(strp(string))

# -*- coding: utf-8 -*-
"""
Created on Mon Dec 18 19:44:17 2017

@author: aeshak
"""
import string
n = input()
s = raw_input()
uppers = set(string.ascii_uppercase)
upperLoc = []
for i in xrange(n):
	if s[i] in uppers:
		upperLoc.append(i)
maxNo = 0
m = len(upperLoc)
pieces = []
start = 0
if upperLoc:
	for i in xrange(n):
		if i in upperLoc:
			if start != i:
				pieces.append(s[start:i])
			start = i+1
	pieces.append(s[start:])
	maxNo = 0
	for piece in pieces:
		maxNo = max(maxNo, len(set(piece)))
else:
	maxNo = len(set(s))
print maxNo

import re
n = input()
s = raw_input()
print max(map(lambda x: len(set(x)), re.split(r'[A-Z]', s)))

n = input()
s = raw_input()
ans = 0
t = []
small = "abcdefghijklmnopqrstuvwxyz"
capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(n):
	if s[i] in small:
		if s[i] not in t:
			t.append(s[i])
			if len(t) > ans:
				ans = len(t)
	else:
		t = []

print ans

n = int(input())
s = input()+"A"
l,r=0,0
ans = 0
while l<n+1:
	if s[l].isupper():
		ans = max(len(set(i for i in s[r:l])),ans)
		l+=1
		r=l
	else:
		l+=1

print(ans)

from collections import Counter

n = int(raw_input())
s = raw_input().strip()

max_set_size = 0
c = Counter()

for letter in s:
    if letter.isupper():
        max_set_size = max(max_set_size, len(c))
        c = Counter()
    else:
        c[letter] += 1

max_set_size = max(max_set_size, len(c))
print max_set_size

ans = 0
combo = set()
pre = -1
input()
for c in input():
  if c.isupper():
    ans = max(ans, len(combo))
    combo = set()
    pre = -1
  elif c != pre:
    combo.add(c)
    pre = c
print(max(ans, len(combo)))

def ideal(s):
    if all(x.islower() for x in s):
        return len(set(s))
    t = s + "A"
    a = " "
    count1 = 0
    for i in range(len(t)):
        if t[i].islower():
            a += t[i]
        else:
            count2 = 0
            b = sorted(a)
            for j in range(1, len(b)):
                if j + 1 < len(b) and b[j + 1] == b[j]:
                    count2 += 1
            if len(b) - count2 > count1:
                count1 = len(b) - count2
            a = " "
    return count1 - 1

n = int(input())
print(ideal(input()))

n = int(input())
a = input()
MAX = 0
end = 0
for i in range(n):
    start = end
    end = start+1
    while a[start:end].islower():
        if MAX < len(set(a[start:end])):
            MAX = len(set(a[start:end]))
        end+=1
        if end > n:
            break
print(MAX)

import re

n=int(input())
ans=0
for w in re.split('[A-Z]',input()):
    if len(w)<1:
        continue
    ans=max(ans,len(set([c for c in w])))
print(ans)

from collections import defaultdict

def solve(N, S):
    ret = 0
    inUpp = S[0].lower() != S[0]
    temp = set()
    for i in xrange(N):
        if inUpp: # uppercase
            if S[i].lower() == S[i]:
                inUpp = False
                temp.add(S[i])
        else: # lowercase
            if S[i].lower() != S[i]:
                ret = max(ret, len(temp))
                temp = set()
            else:
                temp.add(S[i])
        # print 'temp', temp
    ret = max(ret, len(temp))
    return ret

N = int(raw_input())
S = raw_input()
print solve(N, S)

n = int(input().strip())

s = input().strip()

max_set = 0

for x in range(n):
    for y in range(x,n+1):
        char_dict = {}
        if all(c.islower() for c in s[x:y]):
            for z in s[x:y]:
                if z in char_dict:
                    char_dict[z] += 1
                else:
                    char_dict[z] = 1

            if max_set < len(char_dict):
                max_set = len(char_dict)
print(max_set)

'''
	http://codeforces.com/problemset/problem/864/B
'''

value = int(input())
string = input()

def count(result):
	print(len(result) and max(map(len, result)))

def itter(string):
	result = []
	small = set()
	for s in string:
		if s.islower():
			small.add(s)
		else:
			if len(small):
				result.append(small)
			small = set()
	if len(small):
		result.append(small)
	count(result)

itter(string)

n=int(input())
b=input()
a,c,d,e=[],[],[],[]
nom=0
maxx=0
bb=0
for i in range(n):
    a.append(b[i])
    if a[i].islower()==True:
        c.append('m')
    else:
        c.append('b')
#print(c)
for i in range(n):
    if c[i]=='b':
        d.append(i)
if 0 not in d:
    d.insert(0,0)
if c[n-1]!='b':
    d.append(n)
#print(d)
#print(c)
if 'm' not in c:
    print(0)
else:
    for i in range(len(d)-1):
        e.append([])
        for j in range(d[i],d[i+1]):
            if c[j]=='b':
                j+=1
            if b[j] not in e[nom]:
                e[nom].append(b[j])
        #print(e)
        nom+=1
    for i in range(len(e)):
        if len(e[i])>maxx:
            maxx=len(e[i])
    print(maxx)

N = int(input())
X, Max = input(), 0
i = 0
while i < N:
    if X[i].islower():
        MyDict = {}
        while i < N and X[i].islower():
            MyDict[X[i]] = True
            i += 1
        Max = max(Max, len(MyDict))
    i += 1
print(Max)

# UB_CodeForces
# Advice: Falling down is an accident, staying down is a choice
# Location: Here in Bojnurd
# Caption: Again being chased by essi
# CodeNumber: 629

n=int(input())
s = input()
sm = set()
me=0
l=[]
for i in range(n):
    if s[i].islower():
        sm.add(s[i])
        if(me<len(sm)):
            me=len(sm)
            l.append(me)

    elif s[i].isupper():
        sm.clear()
        me=0
if(len(l)>0):
    print(max(l))
else:
    print(0)

n = int(raw_input())
a = list(raw_input())

seq = []

cur = a[0]
temp = []
for i in a:
	if(i<='Z' and i>='A'):
		if(temp!=[]):
			seq.append(temp)
			temp = []
	else:
		temp.append(i)
if(temp!=[]):
	seq.append(temp)
	temp = []

ans = []
for i in seq:
	ans.append(len(set(i)))
if(ans==[]):
	print 0
else:
	print max(ans)

length = int(input(""))
string = input("")

setOfChars = set()
max = 0;

for c in string:
    if c == c.lower():
        setOfChars.add(c)
        if (len(setOfChars) > max):
            #print("Max {} is smaller than length {}".format(max, len(setOfChars)))
            max = len(setOfChars)
    else:
        setOfChars = set()

print(max)

n=int(input())
s=list(input())
ta=[]
ka=[]
x=0
for item in s:
    if item.islower():
        ta.append(item)
    else:
        ka.append(len(set(ta)))
        ta=[]
ka.append(len(set(ta)))
print(max(ka))

import re,sys

l = int(input())
s = input()

if s.isupper():
    print(0)
    sys.exit()

#get consecutive lowercase substrings
ss = re.sub( r"([A-Z])", r" ", s).split()
print(max(len(i) for i in [set(i) for i in ss]))

n = input() + 1
arr = raw_input()+'A'
f = 0
lw = 0
cnt = 0
for x in xrange(n):
	if f == 0 and arr[x].islower():
		#print arr[x],x
		#cnt += 1
		f = 1
		lw = x
	if f == 1 and arr[x].isupper():
		f = 0
		tp = len(list(set(arr[lw:x])))

		if tp > cnt:
			cnt = tp
print cnt

n = int(input())
s = input()

l = []
i = 0
while i < n:
    while i < n and s[i].isupper():
        i += 1
    t = set()
    while i < n and s[i].islower():
        t.add(s[i])
        i += 1
    l.append(t)

m = 0
for i in l:
    if len(i) > m:
        m = len(i)

print(m)

import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
# sys.setrecursionlimit(1000000)
def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n = int(input())
    S = Str()
    temp = set()
    res = 0
    for i in range(n):
        if 97 >= ord(S[i]) <= 122:
            temp.add(S[i])
        else:
            res = max(res,len(temp))
            temp = set()
    print(res)

n = int(input())
symbols = input()

m = 0
for i in range(len(symbols)):
	for j in range(i, len(symbols)+1):
		#print(symbols[i:j])
		if symbols[i:j].islower():
			#print(symbols[i:j], list(set(symbols[i:j])), list(symbols[i:j]))
			if list(set(symbols[i:j]))==list(symbols[i:j]):
				m = max(j-i+1, m)
print(m)

l = []
low = 'qwertyuiopasdfghjklzxcvbnm'
n = int(input())
s = input()

for c in s:
    if(c in low and c not in l):
        l.append(c)
print(len(l))

n=int(input())
s=str(input())
l=[0]
for i in range(len(s)):
    if ord(s[i])>=65 and ord(s[i])<=90:
        l.append(i)
ans=0
l.append(n-1)
for i in range(len(l)-1):
    ls=[]
    for j in range(l[i],l[i+1]):
        if s[j] not in ls and (ord(s[j])>=97 and ord(s[j])<=122):
            ls.append(s[j])
    ans=max(ans,len(ls))
    #print(ls)
print(ans)

num = int(input())
string = input()
lst = []
n = 0
w = 'э'
d = {}

for i in string:
    if i == i.lower() and i not in w:
        n += 1
        w += i
    elif i == i.lower() and i in w:
        continue
    else:
        d[w] = n
        n = 0
        w = 'э'
a = 0
for i in d.values():
    if i > a:
        a = i
    else:
        continue
print(a)

length = int(input(""))
string = input("")

setOfChars = set()
max = 0;

for c in string:
    if c == c.lower():
        setOfChars.add(c)
    else:
        if (len(setOfChars) > max):
            max = len(setOfChars)

print(len(setOfChars))

n = int(input())
t = input()
d = set({})
temp = []
for i in t:
	# temp = []
	if ord(i) >= 65 and ord(i) <= 90:
		temp = []
	if ord(i) >= 97 and ord(i) <= 122:
		if i in temp:
			continue
		elif len(temp):
			d.add(temp.pop())
			d.add(i)
		else:
			temp.append(i)
print(len(d))

n = int(input())
s = str(input())
ans = 0
temp=''
i = 0
while i<len(s):
    if ord(s[i])<97:
        i = i +1
    else:
        while i<len(s) and ord(s[i])>=97:
            temp = temp+ s[i]
            i = i + 1
        t = set(temp)
        ans = max(len(t), ans)
print(ans)

import string
n=input()
s=raw_input()
maxi=-1
ans=[]
for i in range(n):
    t=s[i]
    if t in string.lowercase:
        if t not in ans:
            ans.append(s[i])
    else:
        maxi=max(maxi,len(ans))
        ans=[]
print maxi

#864B
n = int(input())
s = input()
if len(s) == 1:
    print(1)
else:
    parts = []
    i = 0
    string = ""
    while i < len(s):
        if s[i].islower():
            string += s[i]
        else:
            parts.append(string)
            string = ""
        i += 1
    parts.append(string)
    m = 0
    for j in parts:
        j = set(j)
        m = max(len(j),m)
    print(m)

n = int(input())
s = input()
l_upper = []
for i in range(len(s)):
    if s[i].isupper() == True:
        l_upper.append(i)

if len(l_upper) == 0 :
    print(len(set(s)))
elif len(l_upper) == 1:
    print(max(len(set(s[:l_upper[0]])), len(set(s[l_upper[0]: ])) - 1))
else:
    all_len = []
    all_len.append(len(set(s[0: l_upper[0]])))
    for i in range(len(l_upper)- 1):
        all_len.append(len(set(s[l_upper[i]: l_upper[i+1]])) -  1)
    all_len.append(len(set(s[l_upper[-1]: ])))
    print(max(all_len))

n = int(input())

s = input()
s+='A'

t = 0
mp = {}
ans = 0
for i in range(n+1):
    if s[i].islower():
        t+=1
        if s[i] not in mp:
            mp[s[i]]=1
    else:
        ans = len(mp)
        t = 0
        mp = {}
print(ans)

n=int(input())
s=list(input())
f=0
for i in range(n):
    if s[i].isupper():
        f=1
        break
if f==0:
    a=set(s)
    print(len(a))
    exit()
idx=[]
for i in range(n):
    if s[i].isupper():
        idx.append(i)
ans=0
#print(*idx)
for i in range(len(idx)):
    if i==0:
        a=[]
        for i in range(0,idx[i]):
            a.append(s[i])
        a=set(a)
        ans=max(ans,len(a))
    else:
        a=[]
        for i in range(idx[i-1]+1,idx[i]):
            a.append(s[i])
        a=set(a)
        ans=max(ans,len(a))
print(ans)

n = int(input())
s = input()
max_count = 0
count = 0
prev = []
for i in s:
    if i.islower():
        if i not in prev:
            prev.append(i)
            count += 1
        else:
            if count > max_count:
                max_count = count
            prev = []
            count = 1
    else:
        if count > max_count:
            max_count = count
        prev = []
        count = 0
print(max_count)

# May the Speedforce be with us...
'''
for _ in range(int(input())):
arr=list(map(int,input().split()))
n,k=map(int,input().split())
n=int(input())
s=input()

from collections import defaultdict
d=defaultdict()

d=dict()
s=set()
s.intersection()
s.union()
s.difference()

problem statement achhe se padhna hai
age se bhi dekhna hai, piche se bhi dekhna hai
'''
from math import gcd,ceil
from collections import defaultdict as dd
def lcm(a,b):
	return (a*b)//gcd(a,b)
def inin():
	return int(input())
def inar():
	return list(map(int,input().split()))
def ar(element,size):
	return [element for i in range(size)]
def digitsum(num):
	su=0
	while(num):
		su+=num%10
		num//=10
	return su

n=inin()
string=input()
temp=''
prev=string[0]
temp+=prev
for i in string[0:n]:
	if i!=prev:
		temp+=i
	prev=i
cntr=0
curr=0
for i in temp:
	if i.isupper():
		cntr=max(cntr,curr)
		curr=0
	else:
		curr+=1
print(cntr)

n=int(input())
s=input()
max1=0
cnt=0
arr=[]

for i in range(n):
    if(ord(s[i])>=97 and ord(s[i])<=122 and s[i] not in arr):
        arr.append(s[i])
        cnt+=1
    elif(ord(s[i])>=65 and ord(s[i])<=90):
        if(max1<cnt):
            max1=cnt
        cnt=0
        arr=[]
print(max1)

n=int(input())
s=input()
a=[]
b=[]
min=0
for i in range(n):
    if(97<=ord(s[i])<=122):
        if s[i] not  in b:
            a.append(i+1)
            b.append(s[i])
            min=len(a)

    else:
        if(len(a)>min):
            min=len(a)

        a.clear()
        b.clear()

if(min==1):
    print(0)
else:
    print(min)

n = int(input())
s = input()
l = [0]*26
l1 = [0]
c = 0
for e in s:
	if e.islower() and l[ord(e)-97]==0:
		l[ord(e)-97]+=1
		c+=1
		if e==s[n-1]:
			l1.append(c)
	elif ord(e)>=97:
		pass
	elif ord(e)<97 or e==s[n-1]:
		l1.append(c)
		l = [0]*26
		c = 0
print(max(l1))

# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon!
n=int(input())
s=input()

d=""
k=""

start=0
end=0

for i in range(n-1):

	if(s[i]!=s[i+1]):
		d=d+s[i]

for i in d:
	if(ord(i)<=90):
		k=k+' '

	else:
	    k=k+i

k=k.split()
leng=0

for i in k:
	x=len(i)
	leng=max(x,leng)

print(leng)

n = int(input())
s = input()
upper_loc = []
for i in range(n):
    if s[i].isupper() == True:
        upper_loc.append(i)

max_len_set = 0

if len(upper_loc) == 0:
    print(len(set(s)))
elif len(upper_loc) == 1:
    if len(set(s[0:upper_loc[0]])) >= len(set(s[upper_loc[0]: ])):
        print(len(set(s[0:upper_loc[0]])))
    elif len(set(s[0:upper_loc[0]])) < len(set(s[upper_loc[0]: ])):
        print(len(set(s[upper_loc[0]:])) - 1)
else:
    for i in range(len(upper_loc) - 1):
        if len(set(s[upper_loc[i] + 1: upper_loc[i+1]])) > max_len_set:
            max_len_set = len(set(s[upper_loc[i] + 1: upper_loc[i+1]]))
    print(max_len_set)

n = int(input())
str = input()
index = []
for i in range(len(str)):
    if str[i] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':
        index.append(i)
result = 0

for i in range(len(index)-1):
    string = str[index[i]+1:index[i+1]]
    #print(string)
    string = list(string)
    string = set(string)
    result = max(result,len(string))
print(index)
if 0 not in index:
    string = str[:index[0]]
    #print(string)
    string = list(string)
    string = set(string)
    result = max(result, len(string))

if len(str)-1 not in index:
    string = str[index[len(index) - 1]:]
    print(string)
    string = list(string)
    string = set(string)
    result = max(result, len(string))

print(result)

n=int(input())
letter=str(input())
c=0
max=0
for i in range(len(letter)-1):
    if ord(letter[i])>=97 and ord(letter[i])<=122 and letter[i]!=letter[i+1] and ord(letter[i+1])>=97 and ord(letter[i+1])<=122:
        c=c+1
    elif c>max:
        max=c+1
        c=0
print(max)

n=int(input())
s=list(input())
l=0
r=0
lenm=0
b=set()
while r<n:
    if 'a'<=s[r]<='z':
        b.add(s[r])
        r+=1
    else:
        p=s[l:r]
        if len(p)!=0:
            if len(p)!=p.count(p[0]):
                lenm=max(lenm,len(b))
        b=set()
        r+=1
        l=r
lenm=max(lenm,len(b))
print(lenm)

def main():
    t=input()
    n=raw_input()
    n+="A"
    #print n
    if n==2:
        if ord(n[0])<95:
            print 0
        else:
            print 1
    else:
        r=[]
        for i in xrange(t):
            if n[i]!=n[i+1]:
                r.append(n[i])
        if n[i]!=n[t]:
            r.append(n[t])
        count=0L
        p=[]
        #print r
        for i in r:
            #if i==r[len(r)-1] and ord(i)>95:
                #r.append("A")
                #print r
            if ord(i)>95:
                count+=1
            else:
                p.append(count)
                count=0
        print max(p)
if __name__ == '__main__':
    main()

'''input
12
zACaAbbaazzC
'''
n = input()
r = raw_input()
freq = [0 for i in range(len(r))]
for i in range(len(r)):
	if r[i].isupper():
		freq[i] = freq[i-1]+1
	else:
		freq[i] = freq[i-1]
ind = 0
ind1 = 0
ans = 0
for i in range(1,n):
	if freq[i] == freq[i-1]:
		ind1 += 1
	if freq[i] != freq[i-1]:
		ans = max(ans,len(set(r[ind:ind1])))
		ind = i+1
		ind1 = i+1
print ans

alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet_h = alphabet.upper()
alpha = tuple(alphabet)
alpha_h = tuple(alphabet_h)
n = int(input())
s = str(input())
g = 0
i = 1

while i <= n-1:
  if s[i-1] in alpha:
    while s[i] in alpha_h:
     # print(s[i], i)
      g = g + 1
      i = i + 1
   #   print(i)
      if i>=n-1 or s[i] in alpha:
        break
  i = i + 1
i = n - 1
if s[n-1] in alpha_h and g > 0:
  while s[i] in alpha_h and i>=0:
    g = g - 1
    i = i - 1

print(g)

n=int(input())
letter=str(input())
c=0
max=0
for i in range(len(letter)-1):
    if ord(letter[i])>=97 and ord(letter[i])<=122 and letter[i]!=letter[i+1] and ord(letter[i+1])>=97 and ord(letter[i+1])<=122:
        c=c+1
    elif c>max:
        max=c
        c=0
print(max+1)

n = int(input())
symbols = input()

m = 0
for i in range(len(symbols)):
	for j in range(i, len(symbols)):
		if symbols[i:j].islower():
			if list(set(symbols[i:j]))==list(symbols[i:j]):
				m = max(j-i, m)
print(m)

n=input()
s=raw_input()
l=[]
x=""
for i in range(n):
    if s[i].isupper():
        l.append(x)
        x=""
    else:
        x+=s[i]
p=[]
k=0
for j in l:
    k=max(k,len(set(j)))
print k

n = int(input())
a = input()
MAX = 0
end = 0
for i in range(n):
    start = end
    end = start+1
    while a[start:end].islower():
        if MAX < len(set(a[start:end])):
            MAX = len(set(a[start:end]))
        end+=1
        if end >= n:
            break
print(MAX)

n=int(input())
b=input()
a,c,d,e=[],[],[],[]
nom=0
maxx=0
for i in range(n):
    a.append(b[i])
    if a[i].islower()==True:
        c.append('m')
    else:
        c.append('b')
#if c.count('b')<2 or c.count('b')==n:
#    print(0)
#else:
for i in range(n):
    if c[i]=='b':
        d.append(i)
for i in range(len(d)-1):
    e.append([])
    for j in range(d[i]+1,d[i+1]):
        if b[j] not in e[nom]:
            e[nom].append(b[j])
    nom+=1
for i in range(len(e)):
    if len(e[i])>maxx:
        maxx=len(e[i])
print(maxx)

n=int(input())
s=input()
p=set()
l=1
for i in range(n):
    if s[i].isupper():
        if len(p)>l:
            l=len(p)
        p=set()
    else:
        p.add(s[i])
print(l)

n = int(input())
s = list(input())
ans=0
tem=[]
for i in range(n):
    if s[i]>='A' and s[i]<='Z':
        ans=max(ans,len(set(tem)))
        tem=[]
    else:
        tem+=[s[i]]
print(ans)

input()
s=input()
c=0
a=[]
for i in range(1,len(s)):
   if s[i-1]!=s[i] and s[i].islower() and s[i-1].islower():
       a.append(s[i-1])
       a.append(s[i])
print(len(set(a)))

n = int(input())
s = input()
x = ''
for i in s:
    if i.isupper():
        x += ' '
    else:
        x += i
x = x.strip().split(' ')
if len(x):
    print(0)
else:
    x = [len(set(i)) for i in x]
    print(max(x))

n = input()
s = raw_input()
s += 'A'

li = []

cur = 0
maxi = 0
while cur < n:
	while s[cur].isupper():
		cur += 1
		if cur < len(s):
			break
	tmp = ""
	while s[cur].islower():
		tmp += s[cur]
		cur += 1

	if tmp != "":li.append(tmp)

for each in li:
	new = 0
	if len(each) == 1:
		new = 1
	else:
		l = [each[0]]
		for i in each:
			if i != l[-1]:
				l.append(i)
		new  = len(l)

	if new > maxi:
		maxi = new

print maxi

# -*- coding: utf-8 -*-
"""
Created on Mon Dec 18 19:44:17 2017

@author: aeshak
"""
import string
n = input()
s = raw_input()
uppers = set(string.ascii_uppercase)
upperLoc = []
for i in xrange(n):
	if s[i] in uppers:
		upperLoc.append(i)
maxNo = 0
m = len(upperLoc)
pieces = []
start = 0
if upperLoc:
	for i in xrange(n):
		if i in upperLoc:
			if start != i:
				pieces.append(s[start:i])
			start = i+1
	if not pieces and start != 0:
		pieces.append(s[start:])
	maxNo = 0
	for piece in pieces:
		maxNo = max(maxNo, len(set(piece)))
else:
	maxNo = set(s)
print maxNo

input()
s=input()
c=0
a=[]
b=[]
if s[0].islower():
    a.append(s[0])
for i in range(1,len(s)):
    if s[i].isupper():
        b.append(len(set(a)))
        a=[]
    elif s[i-1]!=s[i] and s[i].islower() and s[i-1].islower():
       a.append(s[i-1])
       a.append(s[i])
    elif s[i-1]==s[i] and s[i].islower():
        a.append(s[i])
b.append(len(set(a)))
#print(*b)
print(max(b))

n=int(input())
s=input()
sub=[]
ans=0
for a in range(0,n):
    letter=s[a]
    if letter.islower()!=1:
        ans=max(ans,len(sub))
        sub=[]
        continue
    if letter not in sub:
        sub.append(letter)
print(ans)

n=int(input())
s=input()
l=[]
c=0
for i in s:
    if(i.islower() and i not in l):
        l.append(i)
        c=c+1
print(c)

s = input()
s = input()

def isupper(c):
	return 'A' <= c and c <='Z'

def islower(c):
	return 'a' <= c and c <='z'

def h(c):
	return ord(c) - ord('a')

answer = 0
waiting_lower = True

for i in range(len(s)):
	if islower(s[i]):
		if waiting_lower:
			count = 1
			waiting_lower = False
			appear = [True if _ == h(s[i])  else False for _ in range(26)]
		else:
			if not appear[h(s[i])]:
				count += 1
				answer = max(count,answer)
				appear[h(s[i])] = True
	else:
		waiting_lower = True

print(answer)

n=int(input())
x=input()
c=[]
for i in range(len(x)):
    if(65<=ord(x[i])<=90):
        c.append(i)
l=[]
z=-1
for i in range(len(c)):
    a=set(x[z+1:c[i]])
    l.append(len(a))
    z=c[i]
if(len(c)==0):
    print(len(set(x)))
    exit()
print(max(l))

# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon!
n=int(input())
s=input()

d=""
k=""

for i in range(n-1):

	if(s[i]!=s[i+1]):
		d=d+s[i]
d=d+s[n-1]

for i in d:
	if(ord(i)<=90):
		k=k+' '

	else:
	    k=k+i

k=k.split()
leng=0

for i in k:
	x=len(i)
	leng=max(x,leng)

print(leng)

N = int(input())

s = input()

maxSize = -1
A = []

for i in s:
	if ord(i) >= 97 and ord(i) <= 122:
		if not i in A:
			A.append(i)
			#print(A)
		else:
			if len(A) > maxSize:
				maxSize = len(A)
			A.clear()
			A.append(i)
	else:
		if len(A) > maxSize:
			maxSize = len(A)
		A.clear()

print(maxSize)

t=input()
A=raw_input()
B=[]
Max=0
for i in range(len(A)):
	if(ord(A[i])>=97 and ord(A[i])<=122):
		B.append(A[i])
	else:
		B=list(set(B))
		count=len(B)
		if(count>Max):
			Max=count
		B=[]

print Max

n = int(input())
str = input()
index = [0]
for i in range(len(str)):
    if str[i] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':
        index.append(i)
result = 0

for i in range(len(index)-1):
    string = str[index[i]+1:index[i+1]]
    string = list(string)
    string = set(string)
    result = max(result,len(string))

if 0 not in index:
    string = str[:index[0]]
    string = list(string)
    string = set(string)
    result = max(result, len(string))

if len(str)-1 not in index:
    string = str[index[len(index) - 1]:]
    string = list(string)
    string = set(string)
    result = max(result, len(string))

print(result)

cute = input()
posl = []
temp = str()
for i in cute:
    if i.isupper():
        if temp != '':
            posl.append(temp)
            temp = ''
    else:
        temp = temp + i

maxlen = 0
for i in range(len(posl)):
    posl[i] = ''.join(set(posl[i]))
    if len(posl[i]) > maxlen:
        maxlen = len(posl[i])

print(maxlen)

t=input()
A=raw_input()
B=[]
Max=0
for i in range(len(A)):
	if(ord(A[i])>=97 and ord(A[i])<=122):
		B.append(A[i])
		print B
	elif(ord(A[i])>=65 and ord(A[i])<=90):
		B=list(set(B))
		count=len(B)
		B=[]
		if(count>Max):
			Max=count
print Max

n=int(input())
s=input()+'ZZ'
j=0
m=0
for x in range(n+1):
    if s[x].islower()and s[x]!=s[x+1]:
        j+=1
    elif s[x].isupper():
        m=max(m,j)
        j=0
print(m)

n=int(input())
x=input()
c=[]
for i in range(len(x)):
    if(65<=ord(x[i])<=90):
        c.append(i)
l=[]
z=0
for i in range(len(c)):
    a=set(x[z:c[i]])
    l.append(len(a))
    z=c[i]
if(len(l)==0):
    print(1)
    exit()
print(max(l)-1)

n = int(input())
line = input()

s = set()

# for i in range(len(line)):
# 	for j in range(i + 1, len(line)):
# 		print(line[i:j])

for c in line:
	if c.lower() == c:
		s.add(c)

print(len(s))

N = int(input())

s = input()

maxSize = 0
A = []

for i in s:
	if ord(i) >= 97 and ord(i) <= 122:
		if not i in A:
			A.append(i)
			print(A)
		else:
			if maxSize < len(A):
				maxSize = len(A)
				A.clear()
	else:
		if maxSize < len(A):
			maxSize = len(A)
		A.clear()

if len(A) != 0 and maxSize < len(A):
	maxSize = len(A)

print(maxSize)

"""
NTC here
"""
from sys import setcheckinterval, stdin
setcheckinterval(1000)

# print("Case #{}: {} {}".format(i, n + m, n * m))

def iin(): return int(stdin.readline())

def lin(): return list(map(int, stdin.readline().split()))

from collections import defaultdict as dc

n = iin()
a=input()
ans=0
d=dc(int)
for i in a:
    if 97<=ord(i)<=122:
        d[i]+=1
    else:
        ans=max(ans,len(d))
        d=dc(int)
print(ans)

n = int(input())
cute = input()
posl = []
temp = str()
for i in cute:
    if i.isupper():
        if temp != '':
            posl.append(temp)
            temp = ''
    else:
        temp = temp + i

maxlen = 0
for i in range(len(posl)):
    posl[i] = ''.join(set(posl[i]))
    if len(posl[i]) > maxlen:
        maxlen = len(posl[i])

print(maxlen)

length = int(input(""))
string = input("")

setOfChars = set()
max = 0;

for c in string:
    if c == c.lower():
        setOfChars.add(c)
        max = len(setOfChars)
    else:
        if (len(setOfChars) > max):
            #print("Max {} is smaller than length {}".format(max, len(setOfChars)))
            max = len(setOfChars)
        setOfChars = set()

print(max)

n = int(input())
s = input()

res = 0

for l in range(n,1,-1):
    for offset in range(0,n-l+1):

        chars = set()
        ok = True
        for i in range(offset+1,offset+l):
            if not s[i].islower():
                ok = False
                break
            chars.add(s[i])

        if ok:
            res = max(res, len(chars))
print(res)

n=int(input())
s=input()
sub=[]
ans=0
for a in range(0,n):
    letter=s[a]
    print("letter",letter)
    if letter not in sub:
        sub.append(letter)
    if letter.islower()==False or a==n-1:
        ans=max(ans,len(sub))
        sub=[]
        continue

print(ans)

l = []
ans = 0
low = 'qwertyuiopasdfghjklzxcvbnm'

n = int(input())
s = input()
for c in s:
    if(c not in low):
        ans = max(ans, len(l))
        l.clear()
    elif(c not in l):
        l.append(c)
print(ans)

n = input()
a = raw_input()
ans = 0
found = {}
tempAns = 0
for i in a:
    pos = ord(i)-ord('a')
    if pos >=0 and pos<=26:
        if not(i in found):
            tempAns += 1
            found[i] = True
    else:
        ans = max(ans,tempAns)
        found = {}
        tempAns = 0
print ans

n = input()
s = raw_input()
cur=0
s = s+'Z'
d={}
for i in range(n):
    if s[i] not in d and s[i].isupper()==False:
        d[s[i]]=1
    elif s[i].isupper() ==True:
        if len(d)>cur:
            cur = len(d)
        d={}
    # print d,len(d),s[i],s[i].isupper()
print cur

input()

inp = input()

mmax = 0
chars = []
curr=0
for char in inp:

	if char.isupper():
		#char  - заглавная
		mmax=max(mmax,curr)
		curr=0
		chars=[]

	else:
		#char - строчная
		if char not in chars:
			chars.append(char)
			curr+=1
		else:
			pass

print(mmax)

n=int(input())
s=str(input())
l=[0]
for i in range(len(s)):
    if ord(s[i])>=65 and ord(s[i])<=90:
        l.append(i)
ans=0
l.append(n-1)
for i in range(len(l)-1):
    ls=[]
    for j in range(l[i]+1,l[i+1]):
        if s[j] not in ls:
            ls.append(s[j])
    ans=max(ans,len(ls))
    #print(ls)
print(ans)

def ideal(s):
    if len(s) == 1 and s[0].islower():
        return len(s)
    t = 'A' + s
    a = " "
    count1 = 0
    for i in range(len(t)):
        if t[i].islower():
            a += t[i]
        else:
            count2 = 0
            b = sorted(a)
            for j in range(1, len(b)):
                if b[j] == b[j - 1]:
                    count2 += 1
            if len(b) - count2 > count1:
                count1 = len(b) - count2
            a = " "
    return count1 - 1

n = int(input())
print(ideal(input()))

alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet_h = alphabet.upper()
alpha = tuple(alphabet)
alpha_h = tuple(alphabet_h)
n = int(input())
s = str(input())
g = 0
i = 1

while i <= n-1:
  if s[i-1] in alpha:
    while s[i] in alpha_h:
     # print(s[i], i)
      g = g + 1
      i = i + 1
   #   print(i)
      if i>=n-1 or s[i] in alpha:
        break
  i = i + 1
i = n - 1
if s[n-1] in alpha_h and g > 0:
  while s[i] in alpha_h and i>=0:
    g = g - 1
    i = i - 1
if n == 1 and s[0] in alpha:
  g = 1

print(g)

alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet_h = alphabet.upper()
alpha = tuple(alphabet)
alpha_h = tuple(alphabet_h)
alpha_temp = []
g = []
n = int(input())
s = str(input())

for i in range(n):
  if s[i] in alpha and s[i] not in alpha_temp:
    alpha_temp.append(s[i])
    g.append(len(alpha_temp))
  elif s[i] in alpha_h:
    g = []
    g.append(len(alpha_temp))
    alpha_temp = []

print(max(g))

n = int(input())

s = input()
s+='A'

t = 0
mp = {}
ans = 0
for i in range(n+1):
    if s[i].islower():
        t+=1
        if s[i] not in mp:
            mp[s[i]]=1
    else:
        ans = len(mp)
        t = 0
        mp = {}
print(ans)

length = int(input(""))
string = input("")

setOfChars = set()
max = 0;

for c in string:
    if c == c.lower():
        setOfChars.add(c)
    else:
        if (len(setOfChars) > max):
            max = len(setOfChars)

print(len(setOfChars))

from sys import stdin
upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
s = set()
ans = 0
a = stdin.readline().strip()
for i in a:
 if i in upper:
  ans = max(ans,len(s))
  s = set()
 else:
  s.add(i)
ans = max(ans,len(s))
print ans

n=int(input())
unique=set()
seq=list(input())
for i in seq:
  if i.islower():
    unique.add(i)
print(len(unique))

A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
l=int(input())
w=input()
it=[]
for i in range(l):
  if (w[i] in A) and (w[i] not in it):
    it.append(w[i])
    continue
  elif (w[i] in A) and (w[i] in it):
    continue
  else:
    continue
print(len(it))

#864B
n = int(input())
s = input()
if len(s) == 1:
    print(1)
else:
    parts = []
    i = 0
    string = ""
    while i < len(s):
        if s[i].islower():
            string += s[i]
        else:
            parts.append(string)
            string = ""
        i += 1
    parts.append(string)
    m = 0
    for j in parts:
        j = set(j)
        m = max(len(j),m)
    print(m)

n=int(input())
s=input()
a=set()
res = 0
for i in s:
	if i.islower():
		a.add(i)
		ans=max(res,len(a))
	else:
		a.clear()
print(res)

n = int(input())
s = input()
u = set()
cnt = 0
for i in s:
    if i.islower():
        u.add(i)
    cnt = len(u)
print(cnt)

import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
# sys.setrecursionlimit(1000000)
def Ints(): return map(int, sys.stdin.readline().strip().split())
def Strs(): return map(str, sys.stdin.readline().strip().split())
def Array(): return list(map(int, sys.stdin.readline().strip().split()))
def Str(): return sys.stdin.readline().strip()
def Int(): return int(sys.stdin.readline().strip())
def MOD(): return 1000000007

def power(base, power):
    MOD = 1000000007
    result = 1
    while power > 0:
        if power % 2 == 1:
            result = (result * base) % MOD
        power = power // 2
        base = (base * base) % MOD
    return result

if __name__ == "__main__":
    n = int(input())
    S = Str()
    temp = set()
    res = 0
    for i in range(n):
        if 97 >= ord(S[i]) <= 122:
            temp.add(S[i])
        else:
            res = max(res,len(temp))
            temp = set()
    res = max(res,len(temp))
    print(res)

length = int(input(""))
string = input("")

setOfChars = set()
max = 0;

for c in string:
    if c == c.lower():
        setOfChars.add(c)
    else:
        if (len(setOfChars) > max):
            #print("Max {} is smaller than length {}".format(max, len(setOfChars)))
            max = len(setOfChars)
        setOfChars = set()

print(max)

list = [0 for x in range(26)]
trash = input()
s = input()
for c in s:
    int_c = ord(c) - ord('a')
    if int_c >= 0 and int_c < 26:
        list[ord(c) - ord('a')] = 1
ans = 0
for i in list:
    ans += i
print(ans)

import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())

n = Num()
s = input()
st = -1
for i in range(n):
    if s[i].isupper():
        st = i
        break
ans = 0
u = set()
for i in range(n - 1, st - 1, -1):
    if s[i].isupper():
        u = set()
    else:
        if s[i].islower():
            u.add(s[i])
    ans = max(ans, len(u))
print(ans)

n=input()
s=raw_input()
start,LL=0,0
for i in range(n):
	if s[i] >= 'A' and s[i] <= 'Z':
		D=set(s[start:i])
		if LL < len(D): LL = len(D)
		start=i+1
print LL

a=int(input())
b=str(input())
x=0
z=str("")
while (x<a):
    if(ord(b[x])>=96):
       m=str(b[x])
    else:
       m=str("0")
    x+=1
    z=z+m
z=z.split("0")
x=0
h=0
lol=str("")
while (x<len(z)):
    lol=str(lol)+str(z[x])
    x+=1
n=str(z[0])
if (len(z)<1):
    h=0
elif(len(z)==1 and len(n.replace(n[0],""))==0):
    h=1
else:
    while(x<len(z)):
        n=str(z[x])
        if(len(n)<2):
            vl=0
        elif(len(n.replace(n[0],""))==0):
            h+=0
        else:
            q=len(n)
            h+=1
            while(q>0):
                n=n.replace(n[0],"")
                if(len(n)>0):
                    vl=1
                else:
                    vl=0
                q=len(n)
                h+=vl
                z=lol.replace(n[0],"")
        x+=1
print(h)

ans = 0
combo = 0
pre = -1
input()
for c in input():
  if c.isupper():
    ans = max(ans, combo)
    combo = 0
    pre = -1
  elif c != pre:
    combo += 1
    pre = c
print(max(ans, combo))

n = int(input())
s = str(input())
ans = 0
temp=''
i = 0
while i<len(s):
    if ord(s[i])<97:
        i = i +1
    else:
        while i<len(s) and ord(s[i])>=97:
            temp = temp+ s[i]
            i = i + 1
        t = set(temp)
        ans = max(len(t), ans)
print(ans)

alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet_h = alphabet.upper()
alpha = tuple(alphabet)
alpha_h = tuple(alphabet_h)
alpha_temp = []
g = []
i = 0
n = int(input())
s = str(input())

while i <= n-1:
  if s[i] in alpha and s[i] not in alpha_temp:
    while s[i] in alpha and s[i] not in alpha_temp:
      alpha_temp.append(s[i])
      i = i + 1
      if i > n - 1:
            break
    g.append(len(alpha_temp))
  elif s[i] in alpha_h:
    g = []
    g.append(len(alpha_temp))
    alpha_temp = []
  i = i+1

print(max(g))

n = int(input())
symbols = input()

m = 0
for i in range(len(symbols)):
	for j in range(i, len(symbols)):
		if symbols[i:j].islower():
			if list(set(symbols[i:j]))==list(symbols[i:j]):
				m = max(j-i, m)
print(m)

n=int(input())
s=input()
a=[]
b=[]
min=0
for i in range(n):
    if(97<=ord(s[i])<=122):
        if s[i] not  in b:
            a.append(i+1)
            b.append(s[i])
            if(len(a)>min):
                min=len(a)
    else:
        if(len(a)>min):
            min=len(a)

        a.clear()
        b.clear()

if(min==1):
    print(0)
else:
    print(min)

n = int(input())
s = input()

if s.isupper() or (len(set(s)) == 1):
    print(0)
    exit()

cnt = 0
for i in range(1,n):
    k = s[i-1]
    if s[i].islower():
        if k.islower() and s[i] != k:
            cnt +=1
        else:
            cnt = cnt
    else:
        cnt = cnt
        continue
print(cnt)

def ideal(s):
    if all(x.islower() for x in s):
        return len(set(s))
    t = 'A' + s
    a = " "
    count1 = 0
    for i in range(len(t)):
        if t[i].islower():
            a += t[i]
        else:
            count2 = 0
            b = sorted(a)
            for j in range(1, len(b)):
                if b[j] == b[j - 1]:
                    count2 += 1
            if len(b) - count2 > count1:
                count1 = len(b) - count2
            a = " "
    return count1 - 1

n = int(input())
print(ideal(input()))

n=int(input())
d=input()
lowers=[]
poss={}
for i in range(0,len(d)):
    if (d[i]).islower():
        lowers.append(i)
        poss[i]=1
    else:
        poss[i]=0
setim=set()
for i in range(0,len(d)):
    for j in range(i+1,len(d)):
        f=True
        #print(str(i)+" "+str(j))
        for k in range(i,j+1):
            if poss[k]==0:
                f=False
                break
        if f:
            for k in range(i,j+1):
              setim.add(d[k])

              #print("buldu: "+str(i)+" "+str(j))
print(len(setim))

n=int(input())
s=input()
sub=[]
ans=0
for a in range(0,n):
    letter=s[a]
    if letter.islower()!=1:
        ans=max(ans,len(sub))
        sub=[]
        continue
    if letter not in sub:
        sub.append(letter)
print(ans)

# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon!
n=int(input())
s=input()

d=""
k=""

start=0
end=0

for i in range(n-1):

	if(s[i]!=s[i+1]):
		d=d+s[i]

for i in d:
	if(ord(i)<=90):
		k=k+' '

	else:
	    k=k+i

k=k.split()
leng=0

for i in k:
	x=len(i)
	leng=max(x,leng)

print(leng)

n = int(input())
s = input()
l = [0]*26
l1 = [0]
c = 0
for e in s:
	if e.islower() and l[ord(e)-97]==0:
		l[ord(e)-97]+=1
		c+=1
		if e==s[n-1]:
			l1.append(c)
	elif ord(e)<97 or e==s[n-1]:
		l1.append(c)
		l = [0]*26
		c = 0
	elif ord(e)>=97:
		pass
print(max(l1))