jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
use std::cmp::{max};

fn main() {
    input! {
        n: usize,
        s: String,
    }
    println!("{}", max(0,
             s.chars().map(|c| if c == 'I' {1} else {-1}).collect::<Vec<i32>>().iter().copied()
             .scan(0, |state, i| {
                 *state += i;
                 Some(*state)
             }).max().unwrap())
    )
}
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: i32,
        s: String,
    }
    let (ans, count) = s.chars().fold((0, 0), |(mut an, mut co),  c| {
            if c == 'D' { co -= 1 } 
            if c == 'I' { co += 1 }
            an = cmp::max(co, co);
            (an, co)
            
    });

    println!("{}", ans);
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let S = readLine()!.toArray()
var x = 0
var ans = 0
for c in S {
    if c == "I" {
        x += 1
    } else {
        x -= 1
    }
    ans = max(x, ans)
}
print(ans)
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let S = readLine()!.toArray()
var x = 0
var ans = 0
for c in S {
    if c == "I" {
        x += 1
    } else {
        x -= 1
    }
    ans = max(x, ans)
}
//  [typescript]
const main = (input) => {
  input = input.split('\n');
  const N = parseInt(input[0], 10);
  const S = input[1];
  const x = 0;
  const max = 0;
  for (const i = 0; i<N i++) {
    if (S[i] == 'I') {
      x++;
      max = Math.max(max, x);
    }else{
      x--;
    }
    max = Math.max(max, x);
  }
  console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let n=tn(),s=ts(),x=0,mx=0
  for(let i=0;i<n;i++){
    if(s[i]=='I')x++
    else if(s[i]=='D')x--
    if(x>mx)mx=x
  }
  to(mx)
}
main()
//  [typescript]
const input = require('fs').readFileSync('/dev/stdin', 'utf8')

const n: number = input.split('\n')[0]
const s: string = input.split('\n')[1]
let max = 0
let x = 0
for (let i = 0; i < s.length; i++) {
  if (s[i] === "I") {
    x += 1
  }
  else {
    x -= 1
  }
  if (x > max) {
    max = x
  }
}
console.log(max)
//  [typescript]
const main = (input) => {
  input = input.split('\n');
  const N = parseInt(input[0], 10);
  const S = input[1];
  
  const count = 0;
  for (const i = 0; i<N i++) {
    if (S[i] == 'I') {
      count++;
    }else{
      count-1;
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  input = input.split('\n');
  const N = parseInt(input[0], 10);
  const S = input[1];
  
  const count = 0;
  for (const i = 0; i<S.length i++) {
    if (input[i] == 'I') {
      count++;
    }else{
      count-1;
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
N = int(input())
S = list(input())
cnt = []
for i in range(0,N):
    s1 = set(S[0:i])
    s2 = set(S[i:])
    cnt.append(len(list(s1 & s2)))
print(max(cnt))
//  [python]
N=int(input())
S=input()
max_set=0
for i in range(1,N-1):
  max_set=max(max_set,len(set(S[0:i])&set(S[i:N])))
print(max_set)
//  [python]
N = int(input())
S = input()

ans = 0
for i in range(N):
    ans = max(ans, len(set(S[:i]) & set(S[i:])))
print(ans)
//  [python]
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 <= union:
    max1 = union
  else:
    break

max2 = 0
for i in range(1,half+1):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 <= union:
    max2 = union
  else:
    break
    
ans = max1 if max1>max2 else max2
print(ans)
//  [python]
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 <= union:
    max1 = union
  else:
    break

max2 = 0
for i in range(half):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 <= union:
    max2 = union
  else:
    break
    
ans = max1 if max1>max2 else max2
print(ans)
//  [python]
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 > union:
    break
  else:
    max1 = union

max2 = 0
for i in range(half):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 > union:
    break
  else:
    max2 = union
    
ans = max1 if max1>max2 else max2
print(ans)
//  [java]
import java.util.*;

import jdk.vm.ci.aarch64.AArch64.Flag;
public class Main{
    public static void main( String[] args) {
        Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         String s = sc.next();
         int max = 0;
        for (int i = 0; i < n; i++) {
             String s1 = s.substring(0,i);
             String s2 = s.substring(i);
             int count = 0;
            for(char c ='a'; c <= 'z'; c++){
                boolean flag1 = false;
                for(int j = 0; j < s1.length(); j++){
                    if(c==s1.charAt(j)){
                        flag1 = true;
                        break;
                    }
                }
                boolean flag2 = false;
                for(int j = 0; j < s2.length(); j++){
                    if(c==s2.charAt(j)){
                        flag2 = true;
                        break;
                    }
                }
                if(flag1 && flag2){
                    count++;
                }
            }
            max = Math.max(max, count);
        }   
        System.out.println(max);
    }
}
//  [java]
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String s = scn.next();
      	int max = 0;
        for (int i=1;i<n; ++i){
            String str1 = s.substring(0,i);
            String str2 = s.substring(i);
            int count = 0;
            boolean[] az1 = new boolean[26];
            boolean[] az2 = new boolean[26];
          
            for (int j=0;j<str1.length();j++){
                az1[str1.charAt(j)-'a']=true;
            }
            for (int j=0;j<str2.length();j++){
                az2[str2.charAt(j)-'a']=true;
            }
            for (int j=0;j<26;j++){
                if (az1[j] && az2[j]){
                  count = count + 1;
                }
            }
            max = Math.max(max,count);
        }
        System.out.println(max);
		}
	}
}
//  [java]
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        
        int Max = 1;
        for(int i = 1; i < N; i++){
           int count = 0;
           String str1 = S.substring(0,i);
           String str2 = S.substring(i,N);
           ArrayList <String> list = new ArrayList<>();
           for(int j = 0; j < i; j++){
             if(str2.contains(str1.substring(j,j+1)) && !list.contains(str1.substring(j,j+1))){
                  list.add(str1.substring(j,j+1));
                  count++;
              }
              
             if(Max < count){
                Max = count;
             }
           }
        }
        
        System.out.println(Max);
        
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int t = 0;
        int a[26] = {}, b[26] = {};
        for (int j = 0; j < i; j++) {
            a[s[j] - 'a']++;
        }
        for (int j = i; j < n; j++) {
            b[s[j] - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            if (a[j] && b[j]) t++;
        }
        ans = max(ans, t);
    }

    cout << ans << endl;

    return 0;
}
//  [cpp]
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
using namespace std;
const LL Mod=1e9+7;
const LL Max=1e2+5;
const LL Inf=1e18;
char CH[Max];
LL N,Ans,Cnt,Cnt1[Max],Cnt2[Max];
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	N=Read();scanf("%s",CH+1);
	Fp(I,2,N-1,1){
		Clear(Cnt1);Clear(Cnt2);Cnt=0;
		Fp(J,1,I-1,1){
			Cnt1[CH[J]-'a'+1]++;
		}
		Fp(J,I,N,1){
			Cnt2[CH[J]-'a'+1]++;
		}
		Fp(J,1,30,1){
			if(Cnt1[J]!=0&&Cnt2[J]!=0){
				Cnt++;
			}
		}Ans=max(Cnt,Ans);
	}Write(Ans);
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  int maxcnt = 0;
  for (int i = 0; i < n; i++) {
    vector<int> a(26), b(26);
    for (int j = 0; j < n; j++) {
      if (j < i) {
        a[s[j] - 'a']++;
      } else {
        b[s[j] - 'a']++;
      }
    }
    int cnt = 0;
    for (int j = 0; j < 26; j++) {
      if (a[j] && b[j]) cnt++;
    }
    maxcnt = max(maxcnt, cnt);
  }
  cout << maxcnt << endl;
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;string S;cin>>N>>S;
  priority_queue<int> ans;
  for(int i=1;i<N;i++){
    string A=S.substr(0,i);
    string B=S.substr(i,N-i);
    vector<bool> X(26,false);
    int count=0;
    for(int j=0;j<N-i;j++) X.at(B.at(j)-'a')=true;
    for(int j=0;j<i;j++){
      if(X.at(A.at(j)-'a')){
        X.at(A.at(j)-'a')=false;
        count++;
    }
    ans.push(count);
  }
  cout<<ans.top()<<endl;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;string S;cin>>N>>S;
  priority_queue<int> ans;
  for(int i=1;i<N;i++){
    string A=S.substr(0,i);
    string B=S.substr(i,N-i);
    vector<bool> X(26,false);
    int count=0;
    for(int j=0;j<N-i;j++) X.at(B.at(j)-'a')=true;
    for(int j=0;j<i;j++){
      if(X.at(A.at(j)-'a')) count++;
    }
    ans.push(count);
  }
  cout<<ans.top()<<endl;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> count_char(26);
    rep(i,n){
        count_char[s[i]-'a']++;
    }
    int ans=0;
    rep(i,26){
        if(count_char[i]>1){
            ans++;
        }
    }
    cout << ans << endl;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define NUM_MAX 150

int main(void) {
    int num = get_int();
    char str[NUM_MAX];
    get_str(str, num);

    int i, j;
    static int map[NUM_MAX];
    int ans = 0;
    for(i = 0; i < num-1; i++) {
        map[str[i]-'a']++;
        // [0, i] and [i+1, i]
        int res = {0};
        for(j = i+1; j < num; j++) {
            int idx = str[j] - 'a';
            if(map[idx]) res |= (1<<idx);
        }
        ans = max(ans, __builtin_popcount(res));
    }
    printf("%d\n", ans);
}
//  [c]
#include <stdio.h>

int main()
{
	int N;
	char S[101];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, j, lb[26], ub[26], max = 0, count;
	for (j = 0; j < 26; j++) {
		lb[j] = -1;
		ub[j] = -1;
	}
	for (i = 0; S[i] != 0; i++) {
		if (lb[S[i] - 'a'] == -1) lb[S[i] - 'a'] = i;
		else ub[S[i] - 'a'] = i;
	}
	for (i = 1; S[i] != 0; i++) {
		count = 0;
		for (j = 0; j < 26; j++) {
			if (ub[j] == -1) continue;
			else if (lb[j] < i && ub[j] >= i) count++;
		}
		if (count > max) max = count;
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}
//  [c]
#include<stdio.h>
int main(){

	int n,i,j,k,d=0,c;
	char s[101];

	scanf("%d%s",&n,s);

	for(i=1;i<n-1;i++){
		char x[27]={},y[27]={};

		for(j=0;j<n;j++){
			if(j<i)
				x[s[j]-'a']=1;
			else
				y[s[j]-'a']=1;
		}
		c=0;
		for(k=0;k<27;k++){
			if(x[k]==y[k])
				c+=x[k];
		}
		if(c>d)
			d=c;
	}
	printf("%d",d);
	return 0;
}
//  [c]
#include<stdio.h>

void init_alpha(char*);

int main(){
  int N,cut=1,ans=0;
  scanf("%d",&N);
  getchar();
  char S[N];
  char alpha[25];
  init_alpha(alpha);
  for (int i = 0; i < N; i++)
  {
    scanf("%c",&S[i]);
  }
  
  while (cut<N)
  {
    for (int x = 0; x < cut; x++){
      for (int y = cut; y < N; y++){
        if (S[x]==S[y])
        {
          alpha[S[x]-97]=1;
        }
      }
    }
    int count=0;
    for (int i = 0; i < 25; i++)
    {
      if (alpha[i]==1){ count++;}
    }
    if (ans<count){ans=count;}
    init_alpha(alpha);
    cut++;
  }
  
  
  printf("%d",ans);

  return 0;
}

void init_alpha(char *al){
  for (int i = 0; i < 25; i++){
    al[i]=0;
  }
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    char s[100+5];
    scanf("%d", &n);
    scanf("%s", s);
    
    int ans=0;
    for(int i=1; i<n; i++){
        char x[100+5], y[100+5];
        strncpy(x, s, i);
        x[i]='\0';
        strncpy(y, s+i, n-i);
        y[n-i]='\0';
        
        int c=0;    // count;
        int alpha[30];  // x, yで使われたalphabet
        for(int j=0; j<strlen(x); j++)alpha[x[j]-'a']=1;
        for(int j=0; j<strlen(y); j++){
            if(alpha[y[j]-'a']==1){
                c++;
                alpha[y[j]-'a']=0;
            }
        }
        if(c>ans)ans=c;
        // printf("%s %s %d\n", x, y, c);
    }
    
    printf("%d\n", ans);
    
    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n;
    char s[max];
    int cnt=0, mmax=INT_MIN;
    
    scanf("%d%s", &n, s);
    
    for (int i=0; i<n-1; i++) {
        int a[max]={0}, b[max]={0};
        cnt=0;
        for (int j=i+1; j<n; j++) {
            b[s[j]-97]++;
        }
        for (int k=0; k<i+1; k++) {
            a[s[k]-97]++;
        }
        rep(l, 122-97){
            if (a[l]!=0&&b[l]!=0) {
                cnt++;
            }
        }
        if (cnt>mmax) {
            mmax=cnt;
        }
    }
    
    printf("%d", mmax);
    
    return 0;
}
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	s = input[1];
  	var l=new Array(26);
  	var r=new Array(26);
  	for (var i=0; i<26; i++){
      
      for (l[i]=0; l[i]<n; l[i]++){
          if (s.charCodeAt(l[i])==i+97){
           break; 
          }
      }
      
      for (r[i]=n; r[i]>=l[i]; r[i]+=-1){
          if (s.charCodeAt(r[i])==i+97){
           break; 
          }
       }    
    }
  var counter;
  var max=0;
  for (var j=0;j<n;j++){
    counter=0;
    for (var k=0; k<26; k++){
      if (j>=l[k] && j<r[k]){
       counter++; 
      }
    }
    if (counter>max){
     max=counter; 
    }
  }
  console.log('%d',max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	s = input[1];
  	var char=new Array(26);
  	var l=new Array(26);
  	var r=new Array(26);
  	for (var i=0; i<26; i++){
      
      for (l[i]=0; l[i]<n; l[i]++){
          if (s.charCodeAt(l[i])==i+97){
           break; 
          }
      }
      
      for (r[i]=n; r[i]>=l[i]; r[i]+=-1){
          if (s.charCodeAt(r[i])==i+97){
           break; 
          }
       }
    }
  var counter;
  var max=0;
  for (var j=0;j<n;j++){
    counter=0;
    for (var k=0; k<26; k++){
      if (j>=l[k] && j<r[k]){
       counter++; 
      }
    }
    if (counter>max){
     max=counter; 
    }
  }
  console.log('%d',max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(s){
	s=s.split(/\n/);
	s[0]|=0;
	var a=[],b=[];
	
	for(var i=0;i<s[0];i=(i+1)|0){
		b[s[1][i]]|=0;
		a[s[1][i]]|=0;
		b[s[1][i]]++;
	}
	
	var d=0
	for(var i=0;i<s[0];i=(i+1)|0){
		a[s[1][i]]++;
		b[s[1][i]]--;
		
		var c=0;
		for(var item in a){if(a[item]&&b[item]){c++;}}
		if(d<c){d=c;}
		
	}
	
	console.log(d);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	s = input[1];
  	var char=new Array(26);
  	var l=new Array(26);
  	var r=new Array(26);
  	for (var i=0; i<26; i++){
      
      for (l[i]=0; l[i]<n; l[i]++){
          if (s.charCodeAt(l[i])==i+97){
           break; 
          }
      }
      
      for (r[i]=n; r[i]>=l[i]; r[i]+=-1){
          if (s.charCodeAt(r[i])==i+97){
           break; 
          }
       }
      console.log(String.fromCharCode(i+97)+" "+'%d'+"~"+'%d',l[i],r[i]);
      
    }
  var counter;
  var max=0;
  for (var j=0;j<n;j++){
    counter=0;
    for (var k=0; k<26; k++){
      if (j>=l[k] && j<r[k]){
       counter++; 
      }
    }
    if (counter>max){
     max=counter; 
    }
  }
  console.log('%d',max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	s = input[1];
  	var char=new Array(26);
  	var l=new Array(26);
  	var r=new Array(26);
  	for (var i=0; i<26; i++){
      
      for (l[i]=0; l[i]<26; l[i]++){
          if (s.charCodeAt(l[i])==i+97){
           break; 
          }
      }
      
      if(l[i]<25){
      	for (r[i]=25; r[i]>=l[i]; r[i]+=-1){
          if (s.charCodeAt(r[i])==i+97){
           break; 
          }
        }
      }
      
    }
  var counter;
  var max=0;
  for (var j=0;j<n;j++){
    counter=0;
    for (var k=0; k<26; k++){
      if (j>=l[k] && j<r[k]){
       counter++; 
      }
    }
    if (counter>max){
     max=counter; 
    }
  }
  console.log('%d',max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var n int 
  var s string
  fmt.Scan(&n, &s)
  l := make([]int, n); l[0] |= 1 << uint(s[0] - 'a')
  r := make([]int, n); r[n-1] |= 1 << uint(s[n-1] - 'a')
  for i := 0; i < n - 1; i++ {
    l[i+1] = l[i] | (1 << uint(s[i+1] - 'a'))
  }
  for i := n - 1; i > 0; i-- {
    r[i-1] = r[i] | (1 << uint(s[i-1] - 'a'))
  }

  ans := 0
  for i := 0; i < n - 1; i++ {
    res := l[i] & r[i+1]
    cnt := 0
    for j := uint(0); j < 26; j++ {
      if res >> j & 1 == 1 {
        cnt++
      }
    }
    ans = maxInt(ans, cnt)
  }
  fmt.Println(ans)
}
//  [go]
package main

import (
        "fmt"
)

func solution(n int, s string) int {
        out := -1 << 31
        for i := 1; i < n; i++ {
                x := count(s[:i])
                y := count(s[i:])
                t := 0
                for j := 0; j < 26; j++ {
                        if x[j] > 0 && y[j] > 0 {
                                t++
                        }
                }
                out = max(out, t)
        }
        return out
}

func count(s string) [26]int {
        var a [26]int
        for _, r := range s {
                a[r-'a']++
        }
        return a
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        var n int
        var s string
        fmt.Scan(&n, &s)
        fmt.Println(solution(n, s))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	s := sc.Text()

	ans := 0
	for i := 1; i < n-1; i++ {
		s1 := s[:i]
		s2 := s[i:]

		cnt := 0
		for c := 'a'; c <= 'z'; c++ {
			if strings.Contains(s1, string(c)) && strings.Contains(s2, string(c)) {
				cnt++
			}
		}
		if ans < cnt {
			ans = cnt
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int
var S string

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	S = nextStr()

	ans := -1
	for i := 1; i < N-1; i++ {
		tmp := 0
		for j := 0; j < i; j++ {
			if !strings.Contains(string(S[:j]), string(S[j])) && strings.Contains(string(S[i:]), string(S[j])) {
				tmp++
			}
		}

		ans = maxInt(ans, tmp)
	}

	fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	ans := 0

	fmt.Scan(&n)
	fmt.Scan(&s)

	n = 6
	s = "aabbca"

	r := []rune(s)

	for i := 1; i < n; i++ {
		cnt := 0

		for c := 'a'; c <= 'z'; c++ {
			left := false
			right := false

			for j := 0; j < i; j++ {
				if r[j] == c {
					left = true
				}
			}

			for j := 1; j < i; j++ {
				if r[j] == c {
					right = true
				}
			}

			if left && right {
				cnt++
			}
		}
		
		if ans < cnt {
			ans = cnt
		}
		
	}
	
	fmt.Println(ans)
}
//  [ruby]
n = gets.to_i
s = gets.chomp.chars
hs = Hash.new
s.each_with_index do |c, i|
  hs[c] ||= []
  hs[c] << i
end

# imos method
res =  Array.new(n, 0)
hs.to_a.each do |k, v|
  next if v.size < 2
  l = v[0]
  r = v[-1]
  res[l] += 1
  res[r] -= 1
end
(1...n).each do |i|
  res[i] += res[i - 1]
end
puts res.max
//  [ruby]
gets
h = {}
a = gets.scan(/./)
a.each {|e| h[e] = (h[e]||0) + 1 }
x = m = 0
a.reverse_each {|e|
  if h[e] > 0
    x += 1
    h[e] *= -1
  end
  x -= 1  if 0 == h[e] += 1
  m = x  if m < x
}
p m
//  [ruby]
n = gets.to_i
s = gets.chomp.chars

left = {}
right = {}
s.each { |c| right[c] = right[c].to_i + 1 }
('a'..'z').each { |c| left[c] = 0 }
('a'..'z').each { |c| right[c] = 0 if right[c].nil? }

ans = 0
cnt = 0
s.each do |c|
  b1 = left[c] > 0 && right[c] > 0
  left[c] += 1
  right[c] -= 1
  b2 = left[c] > 0 && right[c] > 0

  if !b1 && b2
    cnt += 1
  elsif b1 && !b2
    cnt -= 1
  end
  ans = cnt if ans < cnt
end
puts ans
//  [ruby]
n = gets.chomp.to_i
s = gets.chomp.split("")
a = []
b = s
ans = 0
(n-1).times do 
    hash_a = Hash.new(0)
    hash_b = Hash.new(0)
    a << b.shift
    a.each do |i|
        hash_a[i] += 1
    end
    b.each do |i|
        hash_b[i] += 1
    end
    max = [hash_b.size,hash_a.size].max
    min = [hash_b.size,hash_a.size].min
    if max == hash_b.size
        big = hash_b
        small = hash_a
    elsif max == hash_a
        big = hash_a
        small = hash_b
    end
    if big == nil || small == nil
        break
    end
    #  p big
    #  p small
    count = 0
    small.each do |i|
        # p big[i[0]]
        if big.include?(i[0]) 
            count += 1
           # [i[1],big[i[0]]].min
        end
    end
    ans = [ans,count].max
end
puts ans
//  [ruby]
n=gets.to_i
s=gets
ans=0
n.times{|l|
  a=Hash.new(0)
  for i in 0..l do
    a[s[i].ord-'a'.ord]=1
  end
  b=Hash.new(0)
  for i in l..n do
    b[s[i].ord-'a'.ord]=1
  end
  tans=0
  a.each{|k,v|
    tans+=1 if b[k]==1
  }
  ans=[ans,tans].max
}
p ans
//  [ruby]
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
S=get_nsp
ans=0
1.upto(N-1) do|i|
  x=S[0..i-1]
  y=S[i..]
  val=(x&y).size
  ans=val if ans<val
end
puts ans
//  [rust]
use std::cmp::max;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::prelude::*;
fn main() {
    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .lines()
        .skip(1)
        .next()
        .expect("not two lines")
        .expect("read error");
    println!("{}", solve(&s.trim()));
}

fn solve(s: &str) -> u32 {
    let mut right: HashMap<char, u32> = HashMap::new();
    let mut left: HashSet<char> = HashSet::new();
    for c in s.chars() {
        let count = right.entry(c).or_insert(0);
        *count += 1;
    }
    let mut commons_max = 0;
    let mut commons = 0;
    for c in s.chars() {
        let right_count = right.get_mut(&c).unwrap();
        *right_count -= 1;
        if left.insert(c) {
            if *right_count > 0 {
                commons += 1;
                commons_max = max(commons, commons_max);
            }
        } else {
            if *right_count == 0 {
                commons -= 1;
            }
        }
    }
    commons_max
}
//  [rust]
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut max_count = 0;
    for i in 0..n {
        let (left, right) = s.split_at(i);
        let l = left.iter().collect::<std::collections::HashSet<_>>();
        let r = right.iter().collect::<std::collections::HashSet<_>>();
        let count = l.iter().filter(|x| r.get(*x).is_some()).count();
        max_count = std::cmp::max(max_count, count);
    }
    println!("{}", max_count);
}
//  [rust]
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let n:u32=read();
    let s:Vec<char>=read::<String>().chars().collect();

    let mut ans:i32 = 0;
    for i in 0..n {
        let mut map1 = HashMap::new();
        let mut map2 = HashMap::new();
        for j in 0..i {
            let cnt = map1.entry(s[j as usize]).or_insert(0);
            *cnt += 1;
        }
        for j in i..n {
            let cnt = map2.entry(s[j as usize]).or_insert(0);
            *cnt += 1;
        }

        let mut cnt:i32 = 0;
        for (k,_v) in &map1 {
            //debug!(i, k, cnt);
            if map2.contains_key(k) { cnt += 1; }
        }
        ans = max(ans, cnt);
    }

    println!("{}", ans);

}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};

fn main() {
    input! {
        _n: usize,
        s: String,
    }
    let s: Vec<_> = s.bytes().map(|c| c - b'a').collect();
    let lefts: Vec<_> = s.iter().scan(0i32, |state, i| {
        *state |= 1 << i;
        Some(*state)
    }).collect();
    let rights: Vec<_> = s.iter().rev().scan(0i32, |state, i| {
        *state |= 1 << i;
        Some(*state)
    }).collect();
    println!("{}", lefts.iter().zip(rights.iter().rev()).map(|(l, r)| (l & r).count_ones()).max().unwrap());
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
        _n: usize,
        s: chars,
    }
    let mut called_time = Vec::new();
    for i in 1..s.len() {
        let mut m1 = (b'a'..=b'z')
                    .map(|c| c as char)
                    .filter(|c| c.is_alphabetic())
                    .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        let mut m2 = (b'a'..=b'z')
                    .map(|c| c as char)
                    .filter(|c| c.is_alphabetic())
                    .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        let v = (b'a'..=b'z').map(|c| c as char).collect::<Vec<_>>();
        for j in 0..i {
            if let Some(x) = m1.get_mut(&s[j]) {
                *x += 1;
            }
        }
        for j in i..s.len() {
            if let Some(x) = m2.get_mut(&s[j]) {
                *x += 1;
            }
        }
        let mut time = 0;
        for j in 0..v.len() {
            if m2[&v[j]] != 0 && m1[&v[j]] != 0 {
                time+=1;
            }
        }
        called_time.push(time);
    }
    if let Some(x) = called_time.iter().max() {
        println!("{}", x);
    }
}
//  [rust]
use std::collections::HashSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let s = sc.chars();

    let result = (1..n - 1).map(|i| {
        let a: HashSet<&char> = s[0..i].iter().collect();
        let b: HashSet<&char> = s[i..n].iter().collect();

        let res = a.intersection(&b).count();
        res
    }).max_by(|x, y| x.cmp(y)).unwrap();

    println!("{}", result);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension [String] {
//    func joined() -> String {
//        return self.joinWithSeparator("")
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let S = readLine()!.toArray()
let alphabet = "abcdefghijklmnopqrstuvwxyz".toArray()
var ans = [Int]()

for i in 1..<N {
    ans += [0]
    for c in alphabet {
        var left = false
        var right = false
        for j in 0..<i {
            if S[j] == c {
                left = true
            }
        }
        for j in i..<N {
            if S[j] == c {
                right = true
            }
        }
        if left && right {
            ans[i-1] += 1
        }
    }
}

print(ans.max())
//  [swift]
import Foundation

let n = Int(readLine()!)!
let s = readLine()!
var ss: [String] = []
var ans = 0
s.forEach { ss.append(String($0)) }
for i in 0..<n-1 {
  let s1 = ss[0...i]
  let s2 = ss[i+1...n-1]
  ans = max(Set(s1).intersection(Set(s2)).count, ans)
}
print(ans)