CF864B.Polycarp and Letters

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string ss consisting only of lowercase and uppercase Latin letters.

Let AA be a set of positions in the string. Let's call it pretty if following conditions are met:

  • letters on positions from AA in the string are all distinct and lowercase;
  • there are no uppercase letters in the string which are situated between positions from AA (i.e. there is no such jj that s[j]s[j] is an uppercase letter, and a1<j<a2a_{1}<j<a_{2} for some a1a_{1} and a2a_{2} from AA ).

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

输入格式

The first line contains a single integer nn ( 1<=n<=2001<=n<=200 ) — length of string ss .

The second line contains a string ss consisting of lowercase and uppercase Latin letters.

输出格式

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

输入输出样例

  • 输入#1

    11
    aaaaBaabAbA
    

    输出#1

    2
    
  • 输入#2

    12
    zACaAbbaazzC
    

    输出#2

    3
    
  • 输入#3

    3
    ABC
    

    输出#3

    0
    

说明/提示

In the first example the desired positions might be 66 and 88 or 77 and 88 . Positions 66 and 77 contain letters 'a', position 88 contains letter 'b'. The pair of positions 11 and 88 is not suitable because there is an uppercase letter 'B' between these position.

In the second example desired positions can be 77 , 88 and 1111 . There are other ways to choose pretty set consisting of three elements.

In the third example the given string ss does not contain any lowercase letters, so the answer is 00 .

首页