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 a_1 < j < a_2 for some a_1 and a_2 from A). 

Write a program that will determine the maximum number of elements in a pretty set of positions.


-----Input-----

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.


-----Output-----

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


-----Examples-----
Input
11
aaaaBaabAbA

Output
2

Input
12
zACaAbbaazzC

Output
3

Input
3
ABC

Output
0



-----Note-----

In 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.

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Implementation

Complete search


Solutions:
import re
n = int(input())
s = input()
a = re.split('[A-Z]+', s)
ans = 0
for i in a:
	ans = max(ans, len(set(i)))
print(ans)


from collections import ChainMap
from collections import Counter
from collections import defaultdict
from collections import deque
from collections import namedtuple
import bisect
import copy
import decimal
import fractions
import functools
import heapq
import itertools
import math
import operator
import pprint
import random
import re
import sys
import time
try:
	import numpy as np
	import scipy as sp
except:
	pass

def is_odd(x):
	return x % 2 == 1

def is_even(x):
	return x % 2 == 0

def cmp(x, y):
	return (x > y) - (x < y)

def sgn(x):
	return cmp(x, 0)

def clamp(x, lo, hi):
	assert lo <= hi
	if x < lo:
		return lo
	elif x > hi:
		return hi
	else:
		return x

def chmax(xmax, x):
	if x > xmax:
		return (x, True)
	else:
		return (xmax, False)

def chmin(xmin, x):
	if x < xmin:
		return (x, True)
	else:
		return (xmin, False)
sys.setrecursionlimit(100000)
PINF = float('inf')
NINF = float('-inf')
EPS = 1e-09

def main():
	N = int(input())
	S = input()
	sets = []
	s = set()
	for c in S:
		if c.isupper():
			if s:
				sets.append(s)
			s = set()
		else:
			s.add(c)
	if s:
		sets.append(s)
	ans = len(max(sets, key=len)) if sets else 0
	print(ans)
main()


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
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))
if idx[len(idx) - 1] != n - 1:
	a = []
	for i in range(idx[len(idx) - 1] + 1, n):
		a.append(s[i])
	a = set(a)
	ans = max(ans, len(a))
print(ans)


from sys import stdin, stderr, maxsize
mod = int(1000000000.0) + 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('\x1b[3{}m'.format(c), *args, '\x1b[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
print(bark())


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()
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())
a = input()
b = 'qwertyuiopasdfghjklzxcvbnm'
p = 0
m = 0
w = set()
for i in range(n):
	if a[i] in b and a[i] not in w:
		w.add(a[i])
		p += 1
	elif a[i] not in b:
		if m < p:
			m = p
		w = set()
		p = 0
else:
	if m < p:
		m = p
print(m)


n = int(input())
s = set()
sl = input()
maxsize = 0
for i in range(n):
	if ord('a') <= ord(sl[i]) <= ord('z'):
		s.add(sl[i])
	else:
		maxsize = max(maxsize, len(s))
		s = set()
maxsize = max(maxsize, len(s))
print(maxsize)


n = int(input())
s = input()
res = 0
for l in range(n, 0, -1):
	for offset in range(0, n - l + 1):
		chars = set()
		ok = True
		for i in range(offset, offset + l):
			if not s[i].islower():
				ok = False
				break
			chars.add(s[i])
		if ok:
			res = max(res, len(chars))
print(res)


length = int(input())
string = input()
size = 0
string = string + 'Z'
A_set = set()
for each in string:
	if each >= 'A' and each <= 'Z':
		if size < len(A_set):
			size = len(A_set)
		A_set = set()
	elif not each in A_set:
		A_set.add(each)
print(size)


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 = list(input()) + ['A']
ans = 0
tem = []
for i in range(n + 1):
	if s[i] >= 'A' and s[i] <= 'Z':
		ans = max(ans, len(set(tem)))
		tem = []
	else:
		tem += [s[i]]
print(ans)


t = int(input())
s = input()
ms = set([])
max = 0
for i in range(t):
	if s[i].islower():
		ms.add(s[i])
		if len(ms) > max:
			max = len(ms)
	else:
		ms = set([])
print(max)


n = int(input())
s = input()
i = 0
ans = 0
while i < n:
	x = set()
	while s[i].islower():
		x.add(s[i])
		i = i + 1
		if i == n:
			break
	ans = max(ans, len(x))
	i = i + 1
print(ans)


n = int(input())
s = input()
ans = 0
ss = set()
for c in s:
	if c.isupper():
		ans = max(ans, len(ss))
		ss = set()
	else:
		ss.add(c)
ans = max(ans, len(ss))
print(ans)


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))


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)


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()))))


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')
i = 0
sem = 0
ans = -1
while i < len(z):
	ss = z[i]
	while len(ss) > 0:
		ss = ss.replace(ss[0], '')
		sem += 1
	ans = max(ans, sem)
	i += 1
	sem = 0
print(ans)


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)
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(ans)


n = int(input())
s = input()
s += 'A'
zag = list('QWERTYUIOPASDFGHJKLZXCVBNM')
mn = -1
tmp = 0
got = []
for i in range(n + 1):
	if s[i] in zag:
		mn = max(mn, tmp)
		tmp = 0
		got = [s[i]]
	elif not s[i] in got:
		tmp += 1
		got.append(s[i])
print(mn)


n = int(input())
s = input()
l = []
count = 0
c = []
for i in range(n):
	if s[i] != s[i].upper() and s[i] not in l:
		l.append(s[i])
		count += 1
	elif s[i] == s[i].upper():
		c.append(count)
		l.clear()
		count = 0
c.append(count)
print(max(c))


n = int(input())
b = input()
a = ['']
for i in b:
	if ord('A') <= ord(i) <= ord('Z'):
		a.append('')
	else:
		a[-1] = a[-1] + i
a = [len(set(list(i))) for i in a]
print(max(a))


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


import os, sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = input().strip()
	cou = [0] * 26
	ans = 0
	for i in s:
		if i.isupper():
			ans = max(ans, 26 - cou.count(0))
			cou = [0] * 26
		else:
			cou[ord(i) - 97] += 1
	ans = max(ans, 26 - cou.count(0))
	cou = [0] * 26
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(input())
c = 0
b = ''
for i in range(n):
	if ord(a[i]) > 96:
		if a[i] not in b:
			b += a[i]
	if ord(a[i]) < 96 or i == n - 1:
		if c <= len(b):
			c = len(b)
		b = ''
print(c)


n = int(input())
s = input()
ans = 0
if n == 1 and ord(s) >= ord('a'):
	ans = 1
for i in range(n):
	sy = set()
	pos = i
	while pos < n and ord(s[pos]) >= ord('a'):
		sy.add(s[pos])
		pos += 1
	if len(sy) > ans:
		ans = len(sy)
print(ans)


n = int(input())
s = input()
(mc, i) = (0, 0)
t = []
c = 0
while i < n:
	if s[i].isupper():
		t = []
		c = 0
	elif s[i] not in t:
		t.append(s[i])
		c += 1
	if c > mc:
		mc = c
	i += 1
print(mc)


import re, sys
l = int(input())
s = input()
if s.isupper():
	print(0)
	sys.exit()
ss = re.sub('([A-Z])', ' ', s).split()
print(max((len(i) for i in [set(i) for i in ss])))


n = int(input())
str = input()
index = []
for i in range(len(str)):
	if str[i] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':
		index.append(i)
result = 0
if index == []:
	string = str[:]
	string = list(string)
	string = set(string)
	result = max(result, len(string))
else:
	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] + 1:]
		string = list(string)
		string = set(string)
		result = max(result, len(string))
print(result)


n = int(input())
s = input()
ans = 0
a = set()
for i in s:
	if 'a' <= i <= 'z':
		if not i in a:
			a.add(i)
	else:
		ans = max(ans, len(a))
		a = set()
print(max(ans, len(a)))


n = int(input())
s = input()
dic = {}
cunt = 0
ans = 0
l = []
for i in range(len(s)):
	if s[i] >= 'a' and s[i] <= 'z':
		if s[i] not in l:
			l.append(s[i])
			dic[s[i]] = 0
		if dic[s[i]] == 0:
			cunt += 1
		dic[s[i]] = dic[s[i]] + 1
		ans = max(ans, cunt)
	else:
		dic = {}
		l = []
		cunt = 0
ans = max(ans, cunt)
print(ans)


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

def ans(s):
	letters = set()
	for c in s:
		if c.isupper():
			letters.clear()
		else:
			letters.add(c)
		yield len(letters)
print(max(ans(s)))


n = input()
s = input()
ln = len(s)
a = []
ans = 0
temp = 0
for i in range(ln):
	if 'A' <= s[i] <= 'Z':
		ans = max(ans, temp)
		a.clear()
		temp = 0
	elif not s[i] in a:
		temp += 1
		a.append(s[i])
ans = max(ans, temp)
print(ans)


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


import re
n = int(input())
s = input()
print(max([len(set(x)) for x in re.split('[A-Z]', s)]))


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)


input()
s = input().strip()
current_set = set()
max_count = 0
for c in s:
	if c.isupper():
		max_count = max(max_count, len(current_set))
		current_set = set()
	else:
		current_set.add(c)
print(max(max_count, len(current_set)))


n = int(input())
str = input()
setOfLetters = set()
out = 0
for i in str:
	if i.islower():
		setOfLetters.add(i)
		out = max(out, len(setOfLetters))
	else:
		setOfLetters.clear()
print(out)


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 = 0
print(max(max_count, count))


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


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)


n = int(input())
s = input()
m = 0
for i in range(len(s)):
	for j in range(i, len(s)):
		ch = s[i:j + 1]
		test = True
		for k in ch:
			if k in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
				test = False
				break
		E = set(ch)
		if test:
			m = max(m, len(E))
print(m)


n = int(input())
s = input()
res = 0
max_res = 0
s2 = ''
for i in range(len(s)):
	if ord(s[i]) > 91 and (not s[i] in s2):
		s2 = s2 + s[i]
		res += 1
	elif ord(s[i]) < 91:
		max_res = max(max_res, res)
		res = 0
		s2 = ''
max_res = max(max_res, res)
print(max_res)


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)


from sys import stdin
import re
n = int(stdin.readline())
s = stdin.readline()[:-1]
ans = 0
m = re.findall('([a-z]+)', s)
for i in m:
	ans = max(ans, len(set(i)))
print(ans)


n = input()
s = input()
z = ''
for c in s:
	if ord(c) >= ord('a') and ord(c) <= ord('z'):
		z += c
	else:
		z += ' '
z = z.split(' ')
alp = range(26)
res = 0
for w in z:
	kek = 26
	for x in alp:
		if w.find(chr(ord('a') + x)) == -1:
			kek -= 1
	res = max(res, kek)
print(res)


n = int(input())
string = input()
longest_distinct = 0
distinct = set([])
for ch in string:
	if ch.islower():
		if not ch in distinct:
			distinct.add(ch)
	else:
		if longest_distinct < len(distinct):
			longest_distinct = len(distinct)
		distinct.clear()
if longest_distinct < len(distinct):
	longest_distinct = len(distinct)
print(longest_distinct)


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 = []
	if i == n - 1:
		if max1 < cnt:
			max1 = cnt
		cnt = 0
		arr = []
print(max1)


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)


input()
s = input()
x = set()
a = 0
l = len(s)
for i in range(0, l):
	for j in range(i, l):
		ss = s[i:j + 1]
		if any((chr(i) in ss for i in range(65, 91))):
			continue
		a = max(a, len(set(ss)))
print(a)


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)))


n = int(input())
s = input()
cnt = 0
mx = 0
sr = ''
for i in range(n):
	if s[i].isupper():
		mx = max(mx, cnt)
		cnt = 0
		sr = ''
	if s[i].islower() and s[i] not in sr:
		sr += s[i]
		cnt += 1
print(max(cnt, mx))


def main():
	N = int(input())
	S = input()
	str_ = set()
	cnt = 0
	for s in S:
		if ord(s) < 97:
			cnt = max(cnt, len(str_))
			str_.clear()
		else:
			str_.add(s)
	cnt = max(cnt, len(str_))
	print(cnt)
main()


n = int(input())
s = input()
m = 0
for i in range(0, n):
	if s[i].lower() == s[i]:
		sset = set(s[i])
		m = max(1, m)
		j = i
		while j != n and s[j] != s[j].upper():
			if s[j] != s[i]:
				sset.add(s[j])
				m = max(m, len(sset))
			j += 1
print(m)


l = int(input())
w = input()
it = set()
c = 0
for i in w:
	if i.islower():
		it.add(i)
		c = max(c, len(it))
	else:
		it.clear()
print(c)


n = int(input())
s = input()
sl = []
for i in s:
	sl += [i]
for i in range(n):
	if sl[i].isupper() == True:
		sl[i] = 'A'
s = ''.join(sl)
sl = s.split('A')
maxx = -1
for i in sl:
	lt = []
	if len(sl) >= 0:
		k = 0
		for j in range(len(i)):
			if i[j] not in lt:
				k += 1
				lt += [i[j]]
		maxx = max(maxx, k)
print(maxx)


l = int(input())
l = ans = 0
a = [0 for i in range(0, 300)]
s = input()
maxn = 0
for l in range(0, len(s)):
	a[ord(s[l])] += 1
	if ord(s[l]) <= 90:
		a = [0 for i in range(0, 300)]
		ans = 0
		continue
	if a[ord(s[l])] == 1:
		ans += 1
	if ans > maxn:
		maxn = ans
print(maxn)


input()
ll = list(input())
dd = {}

def is_up(s):
	return s.lower() != s

def is_lo(s):
	return s.lower() == s
ma = 0
for i in range(len(ll)):
	if is_up(ll[i]):
		dd = {}
	else:
		c = ll[i]
		if c not in dd:
			dd[c] = 1
		ma = max(len(dd), ma)
ma = max(len(dd), ma)
print(ma)


def bitLenCount(x):
	length = 0
	count = 0
	while x:
		count += x & 1
		length += 1
		x >>= 1
	return count
n = input()
s = input()
msk = 0
ans = 0
for i in s:
	x = ord(i) - ord('a')
	if x >= 0 and x <= 25:
		msk |= 1 << x
	else:
		msk = 0
	ans = max(ans, bitLenCount(msk))
print(ans)


from string import ascii_lowercase, ascii_uppercase
n = int(input())
s = input()
flag = 0
r = -1
l = 0
cnt = 0
for i in range(n):
	if s[i] in ascii_lowercase:
		flag = 1
		cnt += 1
if cnt == n:
	print(len(set(s)))
	quit()
if flag == 0:
	print(0)
	quit()
a = []
for i in range(n):
	if s[i] in ascii_uppercase:
		if l == -1 and r == -1:
			l = i
		elif l != -1 and r == -1:
			r = i
		elif l != -1 and r != -1:
			l = r + 1
			r = i
		a.append(s[l:r])
l = r + 1
r = n - 1
a.append(s[l:r + 1])
res = 0
for i in range(len(a)):
	res = max(res, len(set(a[i])))
print(res)


input()
inp = input()
mmax = 0
chars = []
curr = 0
for char in inp:
	if char.isupper():
		mmax = max(mmax, curr)
		curr = 0
		chars = []
	elif char not in chars:
		chars.append(char)
		curr += 1
	else:
		pass
mmax = max(mmax, curr)
print(mmax)


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


n = int(input())
s = input()
res = 0
p = 0
while p < n:
	q = p
	while q < n and s[q].islower():
		q += 1
	if q - p > 0:
		h = dict()
		for i in range(p, q):
			if s[i] in h.keys():
				h[s[i]] += 1
			else:
				h.update({s[i]: 1})
		res = max(res, len(h))
	p = q + 1
print(res)


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()
print(min)


n = int(input())
s = list(input())
s1 = set()
m = 0
for i in range(n):
	if ord(s[i]) >= 97 and ord(s[i]) <= 122:
		if s[i] not in s1:
			s1.add(s[i])
		m = max(m, len(s1))
	else:
		s1.clear()
print(m)


import string
n = int(input())
w = input()
sts = []
st = ''
for ch in w:
	if ch not in string.ascii_uppercase:
		st += ch
	else:
		sts.append(len(set(st)))
		st = ''
if len(st) > 0:
	sts.append(len(set(st)))
print(max(sts))


ls = [set()]
input()
for i in input():
	if i.islower():
		ls[-1].add(i)
	elif ls[-1]:
		ls.append(set())
print(max((len(i) for i in ls)))


import sys
n = input()
string = input()
s = ''
res = 0
for c in string:
	if c.isupper():
		res = max(len(s), res)
		s = ''
	elif c not in s:
		s += c
print(max(res, len(s)))


n = int(input())
s = input()
letters = set()
current = 0
m = 0
for x in range(n):
	if s[x] in letters:
		continue
	elif s[x].isupper():
		m = max(m, len(letters))
		letters = set()
	else:
		letters.add(s[x])
m = max(m, len(letters))
print(m)


from sys import *
from decimal import *
getcontext().prec = 100

class graph:

	def __init__(self, sz, is_oriented):
		self.g = []
		for i in range(sz):
			self.g.append(set())
		self.size = sz
		self.oriented = is_oriented

	def __str__(self):
		out = 'size: {0}\n'.format(self.size)
		for i in range(self.size):
			out += '{0} -> '.format(i + 1)
			for j in self.g[i]:
				out += str(j)
			out += '\n'
		return out

	def addvertex(self):
		self.g.append(set())

	def addedge(self, u, v):
		self.g[u].add(v)
		if self.oriented:
			self.g[v].add[u]

	def neighbours(self, v):
		return self.g[v]

	def is_neighbour(self, u, v):
		return v in self.g[u]

class dsu:

	def __init__(self, number):
		self.par = [z for z in range(number + 1)]
		self.rk = [0] * (number + 1)
		self.size = number

	def find(self, a):
		if a == self.par[a]:
			return a
		self.par[a] = self.find(self.par[a])
		return self.par[a]

	def unite(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return 0
		if self.rk[a] < self.rk[b]:
			(a, b) = (b, a)
		self.par[b] = a
		if self.rk[a] == self.rk[b]:
			self.rk[a] += 1
		return 1

	def create(self):
		self.size += 1
		self.par.append(self.size)
		self.rk.append(0)

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
n = int(input())
s = input()
cnt = set()
maxx = 0
for i in s:
	if 'A' <= i <= 'Z':
		cnt.clear()
	else:
		cnt.add(i)
		maxx = max(maxx, len(cnt))
print(maxx)


input()
letters = input()
sets = [{}]
for c in letters:
	if str.isupper(c):
		sets.append({})
	else:
		sets[-1][c] = True
print(max(map(len, sets)))


n = int(input())
s = input()
A = []
Max = []
for i in s:
	if 'a' <= i <= 'z' and i not in A:
		A.append(i)
	if 'A' <= i <= 'Z':
		Max.append(len(A))
		A.clear()
Max.append(len(A))
print(max(Max))


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)


(n, s) = (int(input()), input())
for i in range(ord('A'), ord('Z') + 1):
	s = s.replace(chr(i), '_')
print(max([len(set(k)) for k in s.split('_')]))


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(input())
s = input()
s += 'A'
l = []
ans = 0
for i in range(n + 1):
	if s[i].islower():
		l.append(s[i])
	if s[i].isupper():
		ans = max(ans, len(set(l)))
		l = []
print(ans)


import math
n = int(input())
input_string = input()
upper_pos = []
for i in range(0, len(input_string)):
	if ord(input_string[i]) >= 65 and ord(input_string[i]) <= 90:
		upper_pos.append(i)
lower_arr = []
if len(upper_pos) == 0:
	lower_arr.append(input_string)
for i in range(0, len(upper_pos)):
	temp = ''
	if i == 0:
		temp = input_string[:upper_pos[i]]
		if len(temp) > 0:
			lower_arr.append(temp)
	if i >= 0 and i < len(upper_pos) - 1:
		temp = input_string[upper_pos[i] + 1:upper_pos[i + 1]]
	if i == len(upper_pos) - 1:
		temp = input_string[upper_pos[i] + 1:]
	if len(temp) > 0:
		lower_arr.append(temp)
max = 0
for i in range(0, len(lower_arr)):
	map = {}
	for j in range(0, len(lower_arr[i])):
		if lower_arr[i][j] in map:
			map[lower_arr[i][j]] += 1
		else:
			map[lower_arr[i][j]] = 1
	if len(map) > max:
		max = len(map)
print(max)


n = int(input())
s = input()
s_1 = ['0' if l.isupper() else l for l in s]
chars = set()
max_ = 0
for char in s_1:
	if char == '0':
		chars = set()
	else:
		chars.add(char)
	max_ = max(max_, len(chars))
print(max_)


import re
n = int(input())
S = input().strip()
s = re.split('[A-Z]+', S)
m = 0
for ss in s:
	x = set(ss)
	m = max(m, len(x))
print(m)


n = int(input())
s = input()
ans = 0
S = set()
for i in range(n):
	if 'a' <= s[i] <= 'z':
		S.add(s[i])
		if len(S) > ans:
			ans = len(S)
	else:
		S = set()
print(ans)


n = int(input())
s = input()
s += 'A'
n += 1
ma = 0
d = set()
for i in range(n):
	if s[i].isupper():
		ma = max(ma, len(d))
		d = set()
	else:
		d.add(s[i])
print(ma)


def Check(c):
	if c >= 'a' and c <= 'z':
		return True
	else:
		return False
n = int(input())
s = input()
mx = 0
st = set()
for i in range(n):
	if Check(s[i]):
		st.add(s[i])
	else:
		st.clear()
	mx = max(mx, len(st))
print(mx)


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()
ans = 0
u = set()
for i in range(n - 1, -1, -1):
	if s[i].isupper():
		u = set()
	elif s[i].islower():
		u.add(s[i])
	ans = max(ans, len(u))
print(ans)


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())
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)))


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
n = I()
s = S()
for l in 'QWERTYUIOPASDFGHJKLZXCVBNM':
	s = s.replace(l, '#')
print(max([len(set(i)) for i in s.split('#')]))


n = int(input())
s = str(input())
s = list(s)
for i in range(len(s)):
	if s[i].upper() == s[i]:
		s[i] = '.'
ch = ''
for i in s:
	ch += i
L = ch.split('.')
dict = {}
i = 0
while i < len(L):
	if L[i] == '':
		L.pop(i)
	else:
		i += 1
if L == []:
	print(0)
else:
	mx = 1
	for i in L:
		d = 0
		dict = {}
		for c in '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'.split('.'):
			dict[c] = 0
		for j in range(len(i)):
			dict[i[j]] += 1
		for c in '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'.split('.'):
			if dict[c] != 0:
				d += 1
		mx = max([mx, d])
	print(mx)


n = int(input())
s = input()
f = [0] * 40
ans = 0
k = 0
for i in range(len(s)):
	g = ord(s[i]) - 97
	if g > -1:
		if f[g] == 0:
			k += 1
			f[g] = 1
	else:
		if k > ans:
			ans = k
		k = 0
		for j in range(30):
			f[j] = 0
if k > ans:
	ans = k
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())
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]
l.append(len(set(x[z + 1:])))
if len(c) == 0:
	print(len(set(x)))
	exit()
print(max(l))


def count_length(string):
	char_set = set()
	for ch in string:
		char_set.add(ch)
	return len(char_set)
big = {chr(i) for i in range(65, 91)}
n = int(input())
s = input()
i = 0
answer = 0
while i < n:
	sss = ''
	if s[i] in big:
		i += 1
	else:
		while i < n and s[i] not in big:
			sss += s[i]
			i += 1
		answer = max(count_length(sss), answer)
print(answer)


alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet_h = alphabet.upper()
alpha = tuple(alphabet)
alpha_h = tuple(alphabet_h)
alpha_temp = []
i = 0
g = []
n = int(input())
s = str(input())
while i <= n - 1:
	if s[i] in alpha and s[i] not in alpha_temp:
		alpha_temp.append(s[i])
		i = i + 1
		g.append(len(alpha_temp))
	elif s[i] in alpha_h:
		g.append(len(alpha_temp))
		alpha_temp = []
		i = i + 1
	else:
		i = i + 1
print(max(g))


n = input()
s = input()
set = set()
max = -1
for char in s:
	if not char.isupper():
		set.add(char)
	else:
		if len(set) > max:
			max = len(set)
		set.clear()
if len(set) > max:
	max = len(set)
print(max)


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


l = int(input())
s = input()
ans = []
k = 0
acc = ''
for i in range(l):
	c = s[i]
	if c.isupper():
		ans += [k]
		k = 0
		acc = ''
	elif c not in acc:
		k += 1
	acc += c
ans += [k]
print(max(ans))


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


def has_upper(s):
	for i in s:
		if i.isupper():
			return True
	return False

def is_pretty(s):
	if has_upper(s):
		return False
	return True

def get_all_substrings(s):
	length = len(s)
	return [s[i:j + 1] for i in range(length) for j in range(i, length)]
n = int(input())
s = input()
len_of_all_pretty = [0]
subs = get_all_substrings(s)
for i in subs:
	if is_pretty(i):
		len_of_all_pretty.append(len(set(i)))
print(max(len_of_all_pretty))


from sys import stdin, stderr, maxsize
mod = int(1000000000.0) + 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('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from collections import Counter, defaultdict
from itertools import permutations

def bark():
	n = I()
	s = S()
	ma = -1
	arr = []
	for i in range(n):
		for j in range(i, n):
			p = [z for z in s[i:j + 1] if z.isupper()]
			if len(p) == 0:
				a = len(set(s[i:j + 1]))
				if a > ma:
					ma = a
	if ma == -1:
		return 0
	else:
		return ma
print(bark())


n = int(input())
s = input()
a = 0
ele = []
prev = ''
cap = list(range(65, 91))
small = list(range(97, 123))
for i in range(n):
	if ord(s[i]) in small and s[i] not in prev:
		a += 1
		prev += s[i]
	elif ord(s[i]) in small and s[i] in prev:
		continue
	else:
		if a != 0:
			ele.append(a)
			a = 0
		prev = ''
if ele == []:
	print(a)
else:
	if a > 0:
		ele.append(a)
		a = 0
		prev = ''
	print(max(ele))


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)]
		elif not appear[h(s[i])]:
			count += 1
			appear[h(s[i])] = True
		answer = max(count, answer)
	else:
		waiting_lower = True
print(answer)


n = int(input())
s = input()
max_set = float('-inf')
unique = []
for i in range(n):
	if s[i].isupper():
		l = len(unique)
		max_set = max(max_set, l)
		unique = []
	else:
		if s[i] not in unique:
			unique.append(s[i])
		if i == n - 1:
			max_set = max(max_set, len(unique))
print(max_set)


n = int(input())
l = []
s = input()
init = 0
for i in range(n):
	if s[i].isupper():
		l.append(s[init:i])
		init = i + 1
l.append(s[init:])
l1 = [len(set(x)) for x in l]
print(max(l1))


import re
n = int(input())
s = input()
ans = 0
ss = re.split('[A-Z]+', s)
print(max(list(map(len, list(map(set, ss))))))


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([])
	return max([len(e) for e in alp])
print(solve())


n = int(input())
s = [i if i.islower() else ' ' for i in input()]
s = ''.join(s).split()
m = 0
for x in s:
	m = max(m, len(set(x)))
print(m)


import math as mt
import sys, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
from collections import defaultdict
n = I()
s = input().strip()
w = set([])
ans = 0
for i in s:
	if i.islower():
		w.add(i)
	else:
		ans = max(len(w), ans)
		w = set([])
print(max(ans, len(w)))


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 sys
import os
import math
import re
n = int(input())
s = input()
soln = []
longest = 0
for c in s:
	if c.islower() and (not c in soln):
		soln.append(c)
		if len(soln) > longest:
			longest = len(soln)
	if c.isupper():
		soln.clear()
print(longest)


n = int(input())
s = input()
dp = [0] * n
t = set()
for i in range(n):
	if s[i].islower():
		dp[i] = dp[i - 1] + (0 if s[i] in t else 1)
		t.add(s[i])
	else:
		dp[i] = 0
		t.clear()
print(max(dp))


n = int(input())
a = input()
b = ''
c = 0
for i in range(n):
	if a[i].islower() and a[i] not in b:
		b += a[i]
	if a[i].isupper() or i == n - 1:
		c = max(len(b), c)
		b = ''
print(c)


import sys
import string
n = sys.stdin.readline()
s = sys.stdin.readline()
lcs = string.ascii_lowercase
ucs = string.ascii_uppercase
best_seen = 0
seens = []
for c in s:
	if c in ucs:
		best_seen = max(best_seen, len(seens))
		seens = []
	elif c in lcs:
		if c not in seens:
			seens.append(c)
best_seen = max(best_seen, len(seens))
print(best_seen)


n = int(input())
s = input()
s += 'L'
s = 'L' + s
k = []
for i in range(n + 2):
	if 65 <= ord(s[i]) <= 90:
		k.append(i)
ans = 0
for i in range(1, len(k)):
	s1 = set(s[k[i - 1] + 1:k[i]])
	ans = max(ans, len(s1))
print(ans)


size = int(input())
n = input()
rez = []
ans = 0
yet = 0
for i in n:
	if ord(i) > 96 and i not in rez:
		rez.append(i)
		yet += 1
	elif ord(i) < 96:
		rez = []
		yet = 0
	ans = max(ans, yet)
print(ans)


n = int(input())
s = input()
x = 0
for i in range(n):
	a = ''
	for j in range(i, n):
		if s[j].isupper():
			if len(a) > x:
				x = len(a)
			break
		elif not s[j] in a:
			a += s[j]
	else:
		if len(a) > x:
			x = len(a)
print(x)


import re
_ = input()
s = input()
ss = [set(i) for i in re.sub('([A-Z])', ' ', s).split()]
print(max((len(i) for i in ss)) if ss else 0)


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))


input()
s = input()
r = ''
import re
s = re.sub('[A-Z]+', ' ', s).split()
if s != []:
	x = max((len(set(i)) for i in s))
else:
	x = 0
print(x)


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


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


n = int(input())
s = input()
import string
sm = string.ascii_lowercase
b = string.ascii_uppercase
ans = 0
h = set()
for i in range(len(s)):
	if s[i] in sm:
		h.add(s[i])
		ans = max(ans, len(h))
	else:
		h = set()
print(ans)


n = int(input())
array = input()
used = []
longest = 0
for i in array:
	if i.isupper():
		if len(used) > longest:
			longest = len(used)
		used = []
	elif i not in used:
		used.append(i)
if len(used) > longest:
	longest = len(used)
print(longest)


from sys import stdin, stdout
from collections import defaultdict as dd
n = int(stdin.readline())
string = stdin.readline().strip()
length = 0
s = set()
for i in string:
	if 97 <= ord(i) <= 122:
		s.add(i)
	else:
		length = max(length, len(s))
		s = set()
length = max(length, len(s))
stdout.write(str(length))


n = int(input())
s = input() + 'Z'
arr = set()
m = 0
for i in s:
	if i.isupper():
		arr.clear()
	else:
		arr.add(i)
		m = max(m, len(arr))
print(m)


n = int(input())
s = str(input().strip())
arr = [[0, []] for _ in range(len(s))]
for i in range(len(s)):
	if not s[i].isupper():
		arr[i][0] = 1
		arr[i][1].append(s[i])
for i in range(1, len(s)):
	if not s[i].isupper():
		if s[i] not in arr[i - 1][1]:
			arr[i][0] += arr[i - 1][0]
			for d in arr[i - 1][1]:
				arr[i][1].append(d)
		else:
			arr[i] = arr[i - 1]
m = 0
for a in arr:
	if a[0] > m:
		m = a[0]
print(m)


lines = input()
lines2 = input()
length = lines
letters = lines2
max = 0
pretty = set()
for i in range(0, int(length)):
	while i < int(length) and letters[i].islower():
		pretty.add(letters[i])
		i += 1
	if len(pretty) > max:
		max = len(pretty)
	pretty.clear()
print(max)


n = int(input())
s = input()
f = 0
cnt = ''
c = mx = 0
for i in range(n):
	if s[i].isupper():
		f = 0
		mx = max(mx, c)
		c = 0
		cnt = ''
	else:
		f = 1
		if s[i] not in cnt:
			cnt += s[i]
			c += 1
if f == 1:
	mx = max(mx, c)
print(mx)


n = int(input())
s = input()
c = set()
k = 0
for i in s:
	if i.isupper():
		k = max(len(c), k)
		c.clear()
	else:
		c.update(i)
k = max(len(c), k)
print(k)


import re
n = input()
s = input()
each = re.sub('[A-Z]', ' ', s)
print(max((len(set(i)) for i in each.split(' '))))


n = int(input())
s = input()
i = 0
letter = []
num = []
while i < n:
	if s[i].islower() and letter.count(s[i]) == 0:
		letter.append(s[i])
	if s[i].isupper() or i == n - 1:
		num.append(len(letter))
		letter = []
	i += 1
if len(num) != 0:
	print(max(num))
else:
	print('0')


n = int(input())
s = input()
ans = []
cnt = []

def all_lower(s):
	for a in range(len(s)):
		if s[a].islower() == False:
			return False
			break
	else:
		return True
if len(s) == 1 and s[0].islower():
	print(1)
	exit()
for i in range(len(s)):
	for j in range(i, len(s)):
		ans.append(s[i:j + 1])
for i in ans:
	if all_lower(i):
		cnt.append(len(set(i)))
if len(cnt) == 0:
	print(0)
else:
	print(max(cnt))


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))


n = int(input())
s = input()
c = set()
dl = 0
s1 = 0
s += 'A'
for i in range(len(s)):
	if 'a' <= s[i] <= 'z':
		c.add(s[i])
	else:
		dl = max(dl, len(c))
		c = set()
print(dl)


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)


n = int(input())
s = input()
cur_set = set()
ans = 0
for c in s:
	if c >= 'a' and c <= 'z':
		cur_set.add(c)
		if len(cur_set) > ans:
			ans = len(cur_set)
	else:
		cur_set = set()
print(ans)


import re
input()
t = re.sub('[A-Z]', ' ', input())
print(max((len(set(s)) for s in t.split(' '))))


n = int(input())
s = input()
mx = 0
cs = set()
for i in s:
	if ord(i) in range(ord('a'), ord('z') + 1):
		cs.add(i)
	else:
		mx = max(mx, len(cs))
		cs.clear()
mx = max(mx, len(cs))
print(mx)


from collections import *

def main():
	n = int(input())
	s = input()
	seen = set()
	ans = 0
	for i in range(n):
		if s[i].isupper():
			ans = max(ans, len(seen))
			seen = set()
		else:
			seen.add(s[i])
	ans = max(ans, len(seen))
	print(ans)
main()


l = int(input())
s = input()
d = ''
cnt = 0
m = 0
for ch in s:
	if ch.islower() and ch not in d:
		d += ch
		cnt = cnt + 1
		m = cnt if cnt > m else m
	elif ch.isupper():
		d = ''
		cnt = 0
print(m)


N = int(input())
s = input()
maxSize = 0
A = []
for i in s:
	if ord(i) >= 97 and ord(i) <= 122:
		if len(A) == 0:
			A.append(i)
		elif not i in A:
			A.append(i)
	else:
		if len(A) > maxSize:
			maxSize = len(A)
		A.clear()
if maxSize < len(A):
	maxSize = len(A)
print(maxSize)


n = int(input())
s = input() + 'A'
d = dict()
ans = 0
for i in range(n + 1):
	if s[i] >= 'a' and s[i] <= 'z' and (s[i] not in d):
		d[s[i]] = True
	elif s[i] >= 'A' and s[i] <= 'Z':
		ans = max(ans, len(d))
		d = dict()
print(ans)


n = int(input())
s = input()
c = []
f = []
for i in range(n):
	if s[i] not in f and s[i] != s[i].upper():
		f.append(s[i])
	elif s[i] == s[i].upper():
		c.append(len(f))
		f = []
c.append(len(f))
print(max(c))


n = int(input())
s = input()
ans = 0
now_ans = 0
lower = []
for el in s:
	if el.islower():
		if el not in lower:
			lower.append(el)
			now_ans += 1
	else:
		if now_ans > ans:
			ans = now_ans
		lower = []
		now_ans = 0
if now_ans > ans:
	ans = now_ans
print(ans)


from sys import stdin, stdout
import string
n = int(stdin.readline().rstrip())
s = list(stdin.readline().rstrip())
lset = str(string.ascii_lowercase)
uset = str(string.ascii_uppercase)
currentSet = set()
maxSize = 0
for letter in s:
	if letter in uset:
		currentSet = set()
	else:
		currentSet.add(letter)
		maxSize = max(maxSize, len(currentSet))
print(maxSize)


n = int(input())
s = str(input())
ans = 0
i = 0
while i < len(s):
	temp = ''
	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 re
n = int(input())
cute = input()
temp = str()
posl = [a for a in re.split('([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()
if len(s) == 1 and s.islower():
	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)


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)


input()
s = input()
arr = []
temp = ''
for x in s:
	if ord(x) <= ord('Z'):
		if temp != '':
			arr.append(temp)
			temp = ''
	else:
		temp += x
if temp != '':
	arr.append(temp)
ans = 0
for y in arr:
	ans = max(ans, len(set(list(y))))
print(ans)


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')
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)
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])
		nom += 1
	for i in range(len(e)):
		if len(e[i]) > maxx:
			maxx = len(e[i])
	print(maxx)


n = int(input())
ans = 0
l = []
for c in input():
	if c.islower():
		l.append(c)
	else:
		ans = max(ans, len(set(l)))
		l = []
ans = max(ans, len(set(l)))
print(ans)


n = int(input())
s = input()
mini = 'abcdefghijklmnopqrstuvwxyz'
e = set()
maxi = 0
for x in s:
	if x in mini:
		e.add(x)
		if len(e) > maxi:
			maxi = len(e)
	else:
		e.clear()
print(maxi)


n = int(input())
s = input()
sm = [-1]
count = []
c = 0
for i in s:
	if ord(i) < 123 and ord(i) > 96:
		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 = int(input())
s = input()
lettresUtilisees = ''
res = 0
for i in range(n):
	if s[i] >= 'a' and s[i] <= 'z':
		flag = False
		for lettre in lettresUtilisees:
			if lettre == s[i]:
				flag = True
				break
		if not flag:
			lettresUtilisees += s[i]
	else:
		lettresUtilisees = ''
	res = max(res, len(lettresUtilisees))
print(res)


n = int(input())
s = input()
ct = [0] * 26
ans = 0
for i in s:
	if ord(i) >= ord('a') and ord(i) <= ord('z'):
		ct[ord(i) - ord('a')] = 1
	ans = max(ans, sum(ct))
	if ord(i) >= ord('A') and ord(i) <= ord('Z'):
		for j in range(26):
			ct[j] = 0
	ans = max(ans, sum(ct))
print(max(ans, sum(ct)))


n = int(input())
s = [str(i) for i in input()]
maxx = 0
elem = set()
for i in s:
	if ord(i) >= 65 and ord(i) <= 90:
		if len(elem) > maxx:
			maxx = len(elem)
		elem = set()
	elif ord(i) >= 97 and ord(i) <= 122:
		elem.add(i)
if len(elem) > maxx:
	maxx = len(elem)
print(maxx)


def solve():
	n = int(input())
	s = list(input())
	ans = 0
	mans = 0
	d = {}
	for i in range(0, n):
		c = s[i]
		if 96 < ord(c) and ord(c) < 123:
			if c not in d:
				d[c] = 1
				ans += 1
		else:
			mans = max(mans, ans)
			ans = 0
			d = {}
	mans = max(mans, ans)
	print(mans)
solve()


n = int(input())
s = input()
e = set()
max_ = 0
lmax = 0
for i in s:
	if 'a' <= i <= 'z':
		if i not in e:
			lmax += 1
			e.add(i)
			max_ = max(max_, lmax)
	else:
		e = set()
		lmax = 0
print(max_)


n = int(input())
s = input()
l = []
j = 0
for i in range(n):
	if s[i] == s[i].upper():
		l.append(s[j:i])
		j = i + 1
l.append(s[j:])
m = 0
for a in l:
	a = set(list(a))
	if m < len(a):
		m = len(a)
print(m)


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()
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)


n = int(input())
stg = input()
mx = []
mxa = []
m = 0
for i in stg:
	if i != i.lower():
		mx.append(m)
		m = 0
		mxa = []
	elif i not in mxa:
		mxa.append(i)
		m += 1
else:
	mx.append(m)
print(max(mx))


bark = int(input())
string = input()
temp = []
tempbegin = []
count = 0
start = 0
temp1 = 0
for i in range(len(string)):
	if string[i].islower():
		tempbegin.append(string[i])
	else:
		if len(set(temp)) < len(set(tempbegin)):
			temp = tempbegin[:]
		tempbegin.clear()
if len(temp) < len(tempbegin):
	temp = tempbegin
print(len(set(temp)))


n = int(input())
arr = list(input())
a = [0 for i in range(26)]
i = 0
t = 0
while i < n:
	if arr[i] == arr[i].lower():
		a[ord(arr[i]) - 97] = 1
	else:
		t = max(t, sum(a))
		a = [0 for i in range(26)]
	i += 1
t = max(t, sum(a))
print(t)


n = int(input())
s = input()
a = [set()]
k = 0
for i in range(len(s)):
	if s[i].upper() == s[i] and a[-1] != set():
		k += 1
		a.append(set())
	elif s[i].lower() == s[i] and s[i] not in a[-1]:
		a[-1].add(s[i])
print(max([len(x) for x in a]))


n = int(input())
s = input()
a = set()
a_max = 0
for e in s:
	if e >= 'A' and e <= 'Z':
		if len(a) > a_max:
			a_max = len(a)
		a = set()
	else:
		a.add(e)
if len(a) > a_max:
	print(len(a))
else:
	print(a_max)


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)


length = int(input())
string = input()
maximum = 0
pretty = set()
for char in string:
	if char.islower():
		pretty.add(char)
	else:
		if len(pretty) > maximum:
			maximum = len(pretty)
		pretty = set()
if len(pretty) > maximum:
	maximum = len(pretty)
print(maximum)


x = int(input())
n = input()
a = set()
ans = 0
for i in n:
	if i == i.lower() and i not in a:
		a.add(i)
		ans = max(ans, len(a))
	elif i != i.lower():
		a.clear()
print(ans)


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)))


import math
import collections
import bisect
import heapq
import time
import random
N = int(input())
S = input()
lowerStrs = []
lstr = ''
for (i, v) in enumerate(S):
	if ord('a') <= ord(v) <= ord('z'):
		lstr += v
	else:
		if lstr:
			lowerStrs.append(lstr)
		lstr = ''
if lstr:
	lowerStrs.append(lstr)
res = 0
for lstr in lowerStrs:
	res = max(res, len(set(lstr)))
print(res)


n = int(input())
a = input()
m = ''
t = []
y = 0
for i in range(n):
	if a[i].isupper():
		m = m + '!'
	else:
		m = m + a[i]
m = m.split('!')
for i in range(len(m)):
	for x in range(len(m[i])):
		if t.count(m[i][x]) == 0:
			t.append(m[i][x])
	if len(t) > y:
		y = len(t)
	t.clear()
print(y)


import sys

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
n = int(input())
S = Str()
res = 0
temp = []
for i in range(n):
	if S[i].lower() == S[i]:
		temp.append(S[i])
	else:
		res = max(res, len(set(temp)))
		temp = []
res = max(res, len(set(temp)))
print(res)


n = int(input())
s = str(input())
e = ''
l = []
for i in range(0, len(s)):
	if s[i].islower():
		e = e + s[i]
	else:
		l.append(len(set(e)))
		e = ''
l.append(len(set(e)))
print(max(l))


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())
word = input()
word += word[-1].upper()
n = 0
ris = 0
temp = []
for x in list(word):
	if x == x.lower():
		temp.append(x)
	else:
		ris = max(ris, len(set(temp)))
		temp.clear()
print(ris)


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))


n = int(input())
s = input() + 'Z'
ans = 0
lst = []
for it in s:
	if 'A' <= it <= 'Z':
		temp = len(set(lst))
		ans = temp if temp > ans else ans
		lst = []
	else:
		lst.append(it)
print(ans)


def main():
	n = int(input())
	s = input() + 'A'
	m = 0
	mm = 0
	a = [False for i in range(26)]
	for i in s:
		if ord('A') <= ord(i) <= ord('Z'):
			m = max(m, mm)
			mm = 0
			a = [False for i in range(26)]
		elif not a[ord(i) - ord('a')]:
			a[ord(i) - ord('a')] = True
			mm += 1
	print(m)
main()


import string
lowers = list(string.ascii_lowercase)
uppers = list
n = int(input())
s = input()
c_set = set()
m = 0
for char in s:
	if char.islower():
		c_set.add(char)
	else:
		c_set = set()
	m = max(m, len(c_set))
print(m)


from collections import Counter
symbols_nr = int(input())
sym_str = input()
ans = 0
curr_ans = 0
curr_set = set()
forbidden_syms = 'QWERTYUIOPASDFGHJKLZXCVBNM'
for sym in sym_str:
	if sym in forbidden_syms:
		curr_ans = len(curr_set)
		curr_set = set()
		ans = max(curr_ans, ans)
	else:
		curr_set.add(sym)
ans = max(ans, len(curr_set))
print(ans)


n = int(input())
s = input()
num = 0
t = set()
for i in range(n):
	if s[i].upper() == s[i]:
		num = max(len(t), num)
		t = set()
	else:
		t.add(s[i])
num = max(len(t), num)
print(num)


import sys
_ = sys.stdin.readline()
string = sys.stdin.readline()
current_set = set()
answer = 0
for character in string:
	if character.islower():
		current_set.add(character)
	else:
		answer = max(answer, len(current_set))
		current_set = set()
answer = max(answer, len(current_set))
print(answer)


s = []
input()
a = input()
p = 0
for i in range(len(a)):
	if 'A' <= a[i] <= 'Z':
		p = max(p, len(s))
		s = []
	elif a[i] not in s:
		s.append(a[i])
print(max(p, len(s)))


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


length = int(input(''))
string = input('')
setOfChars = set()
max = 0
for c in string:
	if c == c.lower():
		setOfChars.add(c)
		if len(setOfChars) > max:
			max = len(setOfChars)
	else:
		setOfChars = set()
print(max)


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)


import re
n = int(input())
s = input()
ans = 0
for c in re.split('[A-Z]', s):
	if len(c) > 0:
		ans = max(ans, len(set(c)))
print(ans)


n = int(input())
s = input()
maximum = 0
processing = False
swet = set()
for c in s:
	if processing:
		if c.islower():
			swet.add(c)
		else:
			processing = False
			maximum = max(maximum, len(swet))
	elif c.islower():
		processing = True
		swet = set()
		swet.add(c)
if processing:
	maximum = max(maximum, len(swet))
print(maximum)


def list_input():
	return list(map(int, input().split()))

def map_input():
	return map(int, input().split())

def map_string():
	return input().split()
n = int(input())
a = list(input())
ans = 0
for i in range(n):
	for j in range(i, n):
		b = a[i:j + 1]
		for k in b:
			if k.lower() != k:
				break
		else:
			b = set(b)
			ans = max(ans, len(b))
print(ans)


n = int(input())
s = input()
q = []
l = []
s += 'A'
for i in range(0, n + 1):
	if ord(s[i]) < 97:
		l.sort()
		if len(l) != 0:
			t = 1
		else:
			t = 0
		for i in range(1, len(l)):
			if l[i] != l[i - 1]:
				t += 1
		q.append(t)
		l = []
	else:
		l.append(s[i])
print(max(q))


import re

def polycarp(string):
	parts = re.split('[A-Z]', string)
	return max((len(list(set(part))) for part in parts))
n = int(input())
mystring = input()
print(polycarp(mystring))


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)


n = int(input())
s = str(input())
res = [[]]
for i in s:
	if ord(i) >= ord('A') and ord(i) <= ord('Z'):
		res.append([])
	else:
		res[-1].append(i)
mx = 0
for i in res:
	mx = max(mx, len(set(i)))
print(mx)


x = input()
s = input()
res = []
max = 0
for l in s:
	if l >= 'a' and l <= 'z':
		if res.count(l) == 0:
			res.append(l)
			if len(res) > max:
				max = len(res)
	else:
		res = []
print(max)


n = int(input())
s = input()
m = 0
for i in range(n):
	d = []
	for j in range(i, n):
		if s[j].islower():
			if s[j] not in d:
				d.append(s[j])
			if len(d) > m:
				m = len(d)
		else:
			if len(d) > m:
				m = len(d)
			break
print(m)


def main():
	_ = int(input())
	ssplit = ''
	for c in input():
		ssplit += '0' if c.isupper() else c
	res = max([len(set(sset)) for sset in ssplit.split('0')])
	print(res)
main()


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
	elif isLowerCase(s[i]):
		flag = 0
		st = set([s[i]])
		count = 1
if maxx < count:
	maxx = count
print(maxx)


n = int(input())
s = input()
(Max, a) = (0, set())
for i in range(n):
	if s[i].isupper():
		Max = max(Max, len(a))
		a.clear()
	else:
		a.add(s[i])
	Max = max(Max, len(a))
print(Max)


_ = int(input())
s = input()
chars = set()
maxval = 0
for c in s:
	if c.isupper():
		maxval = max(maxval, len(chars))
		chars = set()
	else:
		chars.add(c)
maxval = max(maxval, len(chars))
print(maxval)


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 = []
	else:
		a.append(s[i])
b.append(len(set(a)))
print(max(b))


n = int(input())
s = input().strip()
m = set()
result = 0
for i in s:
	if not i.isupper():
		m.add(i)
	else:
		if len(m) > result:
			result = len(m)
		m.clear()
if len(m) > result:
	result = len(m)
print(result)


n = int(input())
s = input()
ans = 0
se = set()
cur = 0
for i in range(n):
	if s[i].islower():
		if s[i] not in se:
			se.add(s[i])
			cur += 1
	else:
		ans = max(ans, cur)
		cur = 0
		se = set()
print(max(ans, cur))


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


n = int(input())
word = input()
i = 0
max = 0
while i < n:
	count = [0] * 26
	while i < n and ord(word[i]) >= 97 and (ord(word[i]) <= 122):
		count[ord(word[i]) - 97] += 1
		i += 1
	counter = 0
	for item in count:
		if item != 0:
			counter += 1
	if max < counter:
		max = counter
	i += 1
print(max)


n = int(input())
S = input()
S1 = S.lower()
S2 = []
ma = 0
p = -1
for i in range(n):
	if p == -1 and S1[i] == S[i]:
		S2.append(S1[i])
		p = 1
	if p == 1 and S1[i] == S[i]:
		S2.append(S1[i])
	if p == 1 and S1[i] != S[i]:
		ma = max(len(set(S2)), ma)
		p = -1
		S2 = []
ma = max(len(set(S2)), ma)
print(ma)


n = int(input())
word = input()
(letters, maxLower, currLower) = (dict(), 0, 0)
for i in range(n):
	if word[i].isupper():
		currLower = 0
		letters = dict()
	elif not letters.get(word[i], False):
		letters[word[i]] = True
		currLower += 1
		maxLower = max(maxLower, currLower)
print(maxLower)


n = int(input())
s = input()
(count, a, c) = (0, [], [])
for i in s:
	if ord(i) in range(97, 123) and i not in a:
		a.append(i)
		count += 1
	elif ord(i) in range(65, 91):
		c.append(count)
		count = 0
		a = []
c.append(count)
print(max(c))


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 = max(ans, len(mp))
		t = 0
		mp = {}
print(ans)


n = int(input())
s = input()
d = ''
k = ''
for i in s:
	if ord(i) <= 90:
		k = k + ' '
	else:
		k = k + i
k = k.split()
leng = 0
for i in k:
	if i.islower():
		i = ''.join(sorted(i))
		d = ''
		for j in range(len(i) - 1):
			if i[j] != i[j + 1]:
				d = d + i[j]
		d = d + i[len(i) - 1]
		x = len(d)
		leng = max(x, leng)
print(leng)


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)


import re
n = int(input())
x = re.findall('[a-z]+', input())
ans = 0
for s in x:
	ans = max(ans, len(set(s)))
print(ans)


n = input()
string = input()
if string.isupper():
	print(0)
else:
	count = 0
	Max = 0
	prev = []
	for i in range(0, int(n)):
		if string[i].islower():
			if count == 0:
				prev.append(string[i])
				count += 1
			elif string[i] not in prev:
				prev.append(string[i])
				count += 1
		elif string[i].isupper() and count != 0:
			if count > Max:
				Max = count
			count = 0
			prev = []
	if count > Max:
		Max = count
	print(Max)


from sys import setcheckinterval, stdin
setcheckinterval(1000)

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 = set()
for i in a:
	if 97 <= ord(i) <= 122:
		d.add(i)
	else:
		ans = max(ans, len(d))
		d = set()
else:
	ans = max(ans, len(d))
print(ans)


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)


(n, ans) = (int(input()), 0)
var = input()
chars = set()
for i in var:
	if i >= 'a' and i <= 'z':
		chars.add(i)
	else:
		ans = max(ans, len(chars))
		chars = set()
ans = max(ans, len(chars))
print(ans)


import re
le = int(input())
st = input()
st = re.split('[A-Z]', st)
out = [0]
for e in st:
	if len(e) == 1:
		out.append(1)
	elif len(e) == 0:
		continue
	else:
		al = []
		for c in e:
			if c not in al:
				al.append(c)
		out.append(len(al))
print(max(out))


n = int(input())
a = input()
ms = 0
k = [0 for i in range(0, 26)]
for i in range(0, n):
	if ord(a[i]) > 96:
		k[ord(a[i]) - 97] = 1
	else:
		if k.count(1) > ms:
			ms = k.count(1)
		k = [0 for i in range(0, 26)]
if k.count(1) > ms:
	ms = k.count(1)
print(ms, end='')


(n, s, p, Max) = (input(), input(), [], 0)
for i in s:
	if 'a' <= i <= 'z' and (not i in p):
		p.append(i)
	elif 'A' <= i <= 'Z':
		Max = max(Max, len(p))
		p = []
print(max(Max, len(p)))


n = int(input())
s = input()
z = ''
for i in s:
	if i >= 'A' and i <= 'Z':
		z += ' '
	else:
		z += i
z = z.split(' ')
sem = 0
ans = -1
for i in z:
	while len(i) > 0:
		i = i.replace(i[0], '')
		sem += 1
	ans = max(ans, sem)
	sem = 0
print(ans)


n = int(input())
s = list(input())
b = []
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))


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 = 'э'
d[w] = n
a = 0
for i in d.values():
	if i > a:
		a = i
	else:
		continue
print(int(a))


l = int(input())
s = input()
max = 0
j = 0
s1 = ''
for i in range(l):
	if ord(s[i]) > 90:
		if not s[i] in s1:
			s1 += s[i]
	else:
		length = len(s1)
		if length > max:
			max = length
		s1 = ''
length = len(s1)
if length > max:
	max = length
print(max)


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 = int(input())
s = list(str(input()))
k = []
max_k = 0
for i in range(n):
	if s[i].islower():
		k.append(s[i])
	if s[i].isupper() or i + 1 == n:
		max_k = max(max_k, len(set(k)))
		k = []
print(max_k)


n = int(input())
s = input()
S = []
tmp = []
i = 0
while i < len(s):
	if s[i].islower() and s[i] not in tmp:
		tmp.append(s[i])
		if i + 1 == len(s):
			S.append(tmp)
			tmp = []
	elif s[i] in tmp and i + 1 == len(s) and s[i].islower():
		S.append(tmp)
		tmp = []
	if s[i].isupper():
		S.append(tmp)
		tmp = []
	i = i + 1
mx = len(S[0])
for i in S:
	if len(i) > mx:
		mx = len(i)
print(mx)


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


n = int(input())
s = list(input())
a_char = ord('a')
for i in range(n):
	if ord(s[i]) < a_char:
		s[i] = '|'
s = ''.join(s)
s = s.split('|')
len_s = len(s)
counts = [None] * len_s
for i in range(len_s):
	counts[i] = len(set(s[i]))
print(max(counts))


n = int(input())
s = input()
m = 0
for i in range(n):
	(x, l) = (s[i], [])
	while x.upper() != x:
		l += x
		i += 1
		if i == n:
			break
		x = s[i]
	m = max(m, len(set(l)))
print(m)


input()
s = input()
met_letters = set()
max_ans = 0
for e in s:
	if e.islower():
		met_letters.add(e)
	else:
		max_ans = max(max_ans, len(met_letters))
		met_letters.clear()
max_ans = max(max_ans, len(met_letters))
print(max_ans)


n = int(input())
s = input() + 'A'
a = set()
maxl = 0
for i in s:
	if i.islower():
		a.add(i)
	else:
		if maxl < len(a):
			maxl = len(a)
		a = set()
print(maxl)


n = int(input())
s = input()
z = []
s = 'A' + s + 'B'
for i in range(len(s)):
	if s[i].isupper():
		z.append(i)
l = []
for i in range(len(z) - 1):
	t = len(set(s[z[i] + 1:z[i + 1]]))
	l.append(t)
print(max(l))


n = int(input())
s = input()
l = []
x = ''
for i in range(len(s)):
	t = ord(s[i])
	if t >= 65 and t <= 90:
		l.append(x)
		x = ''
	else:
		x = x + s[i]
if x != '':
	l.append(x)
if len(l) > 0:
	temp = []
	for i in l:
		temp.append(len(set(i)))
	print(max(temp))
else:
	print(0)


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


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)))


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


n = int(input())
s = str(input())
c = []
count = 0
m = 0
for i in range(n):
	if ord(s[i]) >= 97:
		if s[i] not in c:
			c.append(s[i])
			count = count + 1
			if count > m:
				m = count
	else:
		c = []
		count = 0
print(m)


import string
n = input()
s = input()
(t, ans) = ('', 0)
for i in s:
	if i in string.ascii_uppercase:
		t = ''
	elif i not in t:
		t += i
		if len(t) > ans:
			ans = len(t)
print(ans)


n = int(input())
s = input().strip()
lmain = []
string1 = ''
for i in range(n):
	if s[i].islower():
		string1 += s[i]
	elif string1 != '':
		lmain.append(string1)
		string1 = ''
if string1 != '':
	lmain.append(string1)
length = len(lmain)
max1 = 0
for i in range(length):
	l = []
	for j in range(26):
		l.append(0)
	x = lmain[i]
	len1 = len(x)
	for j in range(len1):
		l[ord(x[j]) - 97] = 1
	c = l.count(1)
	if c > max1:
		max1 = c
print(max1)


x = int(input())
y = input()
z = ''
maxi = 0
for i in range(0, x):
	if y[i].islower():
		flag = 1
		for j in range(0, len(z)):
			if y[i] == z[j]:
				flag = 0
				break
		if flag:
			z = z + y[i]
		if len(z) > maxi:
			maxi = len(z)
	else:
		z = ''
print(maxi)


def read_input() -> (int, str):
	n = int(input())
	s = str(input())
	return (n, s)
(_, s) = read_input()
lst = list(s)
max_counter = 0
counter = 0
actual_dict = list()
for i in lst:
	if i >= 'a':
		if i not in actual_dict:
			actual_dict.append(i)
			counter += 1
			if max_counter < counter:
				max_counter = counter
	else:
		actual_dict = list()
		counter = 0
print(max_counter)


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)


n = int(input())
s = input()
t = 0
for i in range(n):
	if s[i] >= 'a' and s[i] <= 'z':
		x = []
		j = i
		while j < n:
			if s[j] >= 'a' and s[j] <= 'z':
				x.append(s[j])
				j += 1
			else:
				break
		t = max(t, len(set(x)))
print(t)


small = 'abcdefghijklmnopqrstuvwxyz'
big = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n = int(input())
s = list(input())
q = []
f = 0
for i in range(n):
	r = set()
	if s[i] in big:
		if i - f > 0:
			for j in s[f:i]:
				r.add(j)
			q.append(len(r))
		f = i + 1
	elif i == n - 1:
		for j in s[f:i + 1]:
			r.add(j)
		q.append(len(r))
if len(q) == 0:
	print(0)
else:
	print(max(q))


import math
import re

def ria():
	return [int(i) for i in input().split()]
n = ria()[0]
st1 = input()
maxi = 0
st1 = re.sub('[A-Z]', ' ', st1)
for st in st1.split():
	mp = {}
	for i in st:
		a = i
		if a.islower():
			mp[a] = 0
	maxi = max(maxi, len(mp))
print(maxi)


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))


import re
print(max((len({*x}) for x in re.split('[A-Z\n]', [*open(0)][1]))))


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)


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]
		lenm = max(lenm, len(b))
		b = set()
		r += 1
		l = r
lenm = max(lenm, len(b))
print(lenm)


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)


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 = int(input())
s = input()
ss = set()
b = 0
for i in range(n):
	if s[i] >= 'a' and s[i] <= 'z':
		ss.add(s[i])
	else:
		b = max(b, len(ss))
		ss = set()
b = max(b, len(ss))
print(b)


import re
n = int(input())
s = input()
ss = re.split('[A-Z]+', s)
ans = 0
for s in ss:
	count = 0
	for c in 'abcdefghijklmnopqrstuvwxyz':
		count += min(1, s.count(c))
	ans = max(ans, count)
print(ans)