n = int(input())
ans = list(input())
count = 0
a = set()
for i in range(n):
    if ans[i] == 'I':
        count += 1
        a.add(count)
    elif ans[i] == 'D':
        count -= 1
        a.add(count)

print(max(a))


n = int(input())
ans = list(input())
count = 0

for i in range(n):
    if ans[i] == 'I':
        count += 1
    elif ans[i] == 'D':
        count -= 1
print(count + 1)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String s = br.readLine();

        int cnt = 0;
        int max = 0;
        for(int i=0; i<n; i++){
            if('I' == s.charAt(i)){
                cnt++;
            } else if('D' == s.charAt(i)){
                cnt--;
            }

            if(max < cnt) max = cnt;
        }

        System.out.println(max);
    }
}


import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		String S = nextString();

		long c=0;
		long ans = 0;
		for(int i=0;i<S.length();i++){
			if(S.charAt(i)=='I'){
				c++;
			}else{
				c--;
			}
			ans = Math.max(ans,c);
		}
		System.out.println(ans);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String s = sc.next();
        int x = 0;
        int max = 0;
        for(int i=0; i<n; i++){
            Character character = s.charAt(i);
            if(character == 'I') x++;
            else x--;
            max = Math.max(max, x);
        }
        System.out.println(max);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


import java.util.*;
public class Main4 {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		sc.nextLine();
		String st=sc.nextLine();
		int x=0;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(st.charAt(i)=='I') x++;
			else x--;
			ans=Math.max(ans, x);
		}
		System.out.println(ans);
	}

}


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 ans = -1;
        int hagi = 0;
        for(int i=0;i<n;i++){

            if(s.charAt(i) == 'I'){
                hagi++;
            } else {
                hagi--;
            }

            ans =  Math.max(ans,hagi);
        }
        System.out.println(ans);
    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		String s=scan.next();
		int x=0;
		for (int i = 0; i < n; i++) {
			if(s.charAt(i)=='I') x+=1;
			else x-=1;
		}
		System.out.println(x+1);
	}

}


#include<cstdio>
#define max(a,b) (a>b?a:b)
char s[105];
int main()
{
	int n;
	scanf("%d\n%s",&n,s+1);
	int pos=0,ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='I'){
			pos++;
			ans=max(ans,pos);
		}else if(s[i]=='D'){
			pos--;
		}
	}
	printf("%d\n",ans);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	char S[100];
	int i, N, x = 0, max = 0;
	scanf("%d%s", &N, &S);
	for (i = 0; i<N; i++) {
		if (S[i] == 73) {
			x += 1;
			if (x>max) {
				max = x;
			}
		}
		if(S[i]==68){
                       x-=1;
               }
	}
	printf("%d", max);
}


#include <cstdio>
#include <algorithm>
using namespace std;

int n;
char s[101];
int x, ans;

int main(){
	scanf("%d %s", &n, s);
	for(int i=0; i<n; ++i){
		if(s[i]=='I') ++x;
		else --x;
		ans = max(ans, x);
	}
	printf("%d\n", ans);
}


#include<iostream>

int main()
{
    int n,x=0,maxim;
    std::string str;
    std::cin>>n;
    std::cin.ignore();
    std::cin>>str;
    for(int i=0;i<n;i++){
        if(str[i]=='I')x++;
        else x--;
        if(i==0){
            maxim = x;
        }
        else if(x>maxim){
            maxim = x;
        }
    }
    std::cout<<maxim<<std::endl;
}


#include<bits/stdc++.h>

int main(){
 int n;
 cin >> n;
 string s;
 cin >> s;
  int ans = 0;
  int maxans = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'I') ans ++;
    else ans--;
    maxans = max(ans,maxans);
  }
  return 0;
}


#include <bits/stdc++.h>
// #include<atcoder/all>
// using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int n; cin >> n;
    string s; cin >> s;
    int ans = -1;
    int x = 0;
    rep(i,n) {
        if (s[i] == 'I') x++;
        else x--;
        if (ans < x) ans = x;
    }
    cout << ans << endl;
}


#include<stdio.h>
int main()
{
int i=0,n,x=0,max=0;
char ch[1000];
scanf("%d",&n);
scanf("%s",ch);
while(ch[i]!=NULL)
{
    if(ch[i]=='I')
    {
        x += 1;
    }
    else if(ch[i]=='D')
    {
        x -= 1;
    }

    if(x>max)
    {
        max=x;
    }
    i++;
}
printf("%d",max);

}


#include <string.h>
#include <stdio.h>

int main(void)
{
    int a,i,count = 0,we = 0;
    char b[100];
    scanf("%d%s",&a,b);
    for (i = 0; i < strlen(b); i++) {
        if (b[i] == 'I') {
            count++;
        }else{
            count--;
        }
        if (we < count) {
            we = count;
        }
    }
    printf("%d\n",we);
    return 0;
}


s,a,c;
main(){
  for(;getchar_unlocked()>10;);
  for(;(c=getchar_unlocked())>10;s=s<--a?a:s)a+=(c&1)<<1;
  printf("%d",s);
}


#include<stdio.h>
int main(){
  int n;
  scanf("%d\n",&n);
  char str[n+1];
  scanf("%s\n",str);
  int x=0,i,k,d=0;
  for(i=0;i<n;i++){
    if(str[i]=='I') x++;
    if(str[i]=='D') x--;
    k = x;
    if(k>d) d=k;
  }
  printf("%d\n",k);
  return 0;
}


#include<stdio.h>
int main(){
  int n;
  scanf("%d\n",&n);
  char str[n+1];
  int x=0,i;
  for(i=0;i<n;i++){
    if(str[i]=='I') x++;
    if(str[i]=='D') x--;
  }
  printf("%d\n",x);
  return 0;
}


#include<stdio.h>
int main(){
  int n;
  scanf("%d\n",&n);
  char str[n+1];
  int x,i;
  for(i=0;i<n;i++){
    if(str[i]=='I') x++;
    if(str[i]=='D') x--;
  }
  printf("%d\n",x);
  return 0;
}


// ABC052 B - Increment Decrement
'use strict'

function Main(input) {
    const tmp = input.trim().split('\n');
    const N = Number(tmp[0])
    const S = tmp[1].split('')
    // console.log(N, S);

    let result = 0;
    let x = 0;
    for (const v of S) {
        if (v === 'I') {
            x++;
        } else if (v === 'D') {
            x--;
        }
        if (x > result) {
            result = x;
        }
    }

    console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let N = input[0].split(' ')[0]
	let S = input[1].split(' ')[0]
	let Xs = []
	let x = 0
	Xs.push(x)
	for(let i = 0; i < N; i++) {
		if(S[i] === 'D') {
			Xs.push(--x)
		} else {
			Xs.push(++x)
		}
	}
	console.log(Math.max(...Xs))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


"use strict";
const main = arg => {
  let info = arg.split("\n");
  let max = 0;
  let tmp = 0;
  for(let t of info[1]){
    if(t == "I"){
      tmp += 1;
    } else {
      tmp -= 1;
    }
    if(max < tmp){
    	max = tmp;
    }
  }

  console.log(max);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main (input) {
  var args = input.split("\n");
  var ar = args[1].split("");
  var x = 0;
  var a = [0];
  for(var i = 0; i < ar.length; i++){
    if ar[i] === "I"
      x++;
      a.push(x);
    else
      x--;
      a.push(x);
  }

  var ans = Math.max.apply(null, a);
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main (input) {
  var args = input.split("\n");
  var ar = args[1].split("");
  var x = 0;
  var a = [0];
  for(var i = 0; i < ar.length; i++){
    if arra[i] === "I"
      x++;
      a.push(x);
    else
      x--;
      a.push(x);
  }

  var ans = Math.max.apply(null, a);
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main (input) {
  var args = input.split("\n");
  var arra = args[1].split("");
  var x = 0;
  var a = [0];
  for(var i = 0; i < arra.length; i++){
    if arra[i] === "I"
      x++;
      a[i + 1] = x;
    else
      x--;
      a[i + 1] = x;
  }

  var ans = Math.max.apply(null, a);
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	var s string
	fmt.Scanf("%s", &s)

	res := 0
	x := 0
	for _, c := range s {
		if c == 'I' {
			x += 1
		}
		if c == 'D' {
			x -= 1
		}
		if res < x {
			res = x
		}
	}

	fmt.Println(res)
}


package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() 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 main() {
	n := nextInt()
	s := next()

	m, x := 0, 0
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'I':
			x++
		case 'D':
			x--
		}

		if m < x {
			m = x
		}
	}

	fmt.Println(m)
}


package main

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

//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 pow(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
}

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

	var ans, now int
	for i := 0; i < N; i++ {
		if string(S[i]) == "I" {
			now++
			ans = maxInt(ans, now)
		} else {
			now--
		}
	}

	fmt.Println(ans)
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

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)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	S := getString()
	x := 0
	max := 0
	for _, c := range S {
		if c == 'I' {
			x++
		} else {
			x--
		}

		if max < x {
			max = x
		}
	}
	fmt.Println(max)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for _, v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

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

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func getStringArray(n int) []string {
	array := make([]string, n)
	for i := 0; i < n; i++ {
		array[i] = getString()
	}
	return array
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

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

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

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 isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


package main

import (
	"fmt"
)

func main() {
	var n, x, ans int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	for i := 0; i < n; i++{
		if s[i] == 'I'{
			x++
		} else {
			x--
		}
		ans = max(ans, x)
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b{
		return a
	} else {
		return b
	}
}
package main

import (
	"fmt"
)

func main() {
	var n, x, ans int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	for i := 0; i < n; i++{
		if s[i] == 'I'{
			x++
		} else {
			x--
		}
		ans = max(ans, x)
	}
	fmt.Println(ans)
}

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


package main

import (
	"fmt"
)

func main() {
	var n, x, ans int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	for i := 0; i < n; i++{
		if s[i] == 'I'{
			x++
		} else {
			x--
		}
		ans = max(ans, x)
	}
}

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


n = gets.to_i
s = gets
m = 0
max = 0
for i in 0...n
  if s[i] == 'I'
    m += 1
    if m > max
      max = m
    end
  else
    m -= 1
  end
end

puts max


n = gets.to_i
s = gets.chomp
x = 0
ans = []
for i in 0..n-1
  if s[i] == "I"
    x += 1
    ans << x
  else
    x -= 1
    ans << x
  end
end

if ans.max < 0
  puts 0
else
  puts ans.max
end


N = gets.to_i
S = gets.chomp
x = 0
y = x
S.split('').each do |s|
    if s == 'I'
        x += 1
    else
        x -= 1
    end
    y = x if y < x
end
puts y


n = gets.to_i
s = gets.split('').map(&:to_s)
x = 0
px = 0
ans = 0
n.times do |i|
	px = x
	if s[i] == 'I'
		x+=1
	else
		x-=1 if x > 0
	end
	ans = x if px < x
end
puts ans


n = gets.to_i
s = gets.split('').map(&:to_s)
x = 0
px = 0
ans = 0
n.times do |i|
	px = x
	if s[i] == 'I'
		x+=1
	else
		x-=1
	end
	if x > px
		ans = x
	end
end
puts ans


n = gets.to_i
s = gets.split('').map(&:to_s)
x = 0
px = 0
ans = 0
n.times do |i|
	px = x
	if s[i] == 'I'
		x+=1
	else
		x-=1
	end
	ans = x if (px < x)
end
puts ans


#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        S: String,
    }

    let mut x: i64 = 0;
    let mut ans: i64 = 0;

    for i in 0..N {
        let s: &str = &S[i..=i];
        if s == "I" {
            x += 1;
        } else {
            x -= 1;
        }

        ans = max(ans, x);
    }

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


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)*}
  };
}

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)*}
  };
}

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<_>>()
  };

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

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

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

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

pub trait LexicalPermutation {
    /// Return `true` if the slice was permuted, `false` if it is already
    /// at the last ordered permutation.
    fn next_permutation(&mut self) -> bool;
    /// Return `true` if the slice was permuted, `false` if it is already
    /// at the first ordered permutation.
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    /// Original author in Rust: Thomas Backman <serenity@exscape.org>
    fn next_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the last-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Find the rightmost element larger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }

        // Step 3: Swap that element with the pivot
        self.swap(j, i - 1);

        // Step 4: Reverse the (previously) weakly decreasing part
        self[i..].reverse();

        true
    }

    fn prev_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly increasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the first-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Reverse the weakly increasing part
        self[i..].reverse();

        // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }

        // Step 4: Swap that element with the pivot
        self.swap(i - 1, j);

        true
    }
}

#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::Ordering::*;
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet, VecDeque};
use std::io::{stdout, BufWriter, Write};
use std::mem::swap;

fn main() {
    input! {
        mut n: i32,
        s: chars,
    }
    let mut x = 0;
    let mut ans = 0;
    for (i, &v) in s.iter().enumerate() {
        if v == 'I' {
            x += 1;
        } else if v == 'D' {
            x -= 1;
        } else {
            continue;
        }
        ans = max(ans, x);
    }
    echo!(ans);
}


use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let n:i32 = procon_read()[0];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut s = buf.trim().chars().collect::<Vec<char>>();
	let mut x = 0;
	let mut maxi = 0;
	for i in s {
		if i == 'I' {
			x += 1;
		}else{
			x -= 1;
		}
		maxi = max(x, maxi);
	}
	println!("{}", maxi);
}


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()
             .scan(0, |state, i| {
                 *state += i;
                 Some(*state)
             }).max().unwrap())
    )
}


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


#[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);
}


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)


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


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


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


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)


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


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


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


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)


N = int(input())
S = input()

ans = 0
for i in range(N):
    ans = max(ans, len(set(S[:i]) & set(S[i:])))
print(ans)


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)


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)


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)


import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		int x = r.ri();
		String s = r.str();
		int[] lArr = new int[26];
		int[] rArr = new int[26];
		lArr[s.charAt(0)-'a'] = 1;
		for(int i = 1; i<s.length(); i++)
			rArr[s.charAt(i)-'a']++;

		int max = 0;
		if(rArr[s.charAt(0)-'a'] > 0) max=1;
		int matches = max;
		//for(int i = 1; i<s.length(); i++)
		//{
		//	if(rArr[s.charAt(i)-'a'] == 1 && sArr[])
		//}
		for(char c : s.substring(1).toCharArray())
		{
			if(rArr[c-'a'] == 1 && lArr[c-'a'] > 0) matches--;
			if(rArr[c-'a'] > 1 && lArr[c-'a'] == 0) matches++;
			max = Math.max(max, matches);
			rArr[c-'a']--;
			lArr[c-'a']++;
		}
		print(max);
	}

	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}

	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}

	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}

		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


import java.util.*;
import java.io.*;
import java.util.function.*;
// import lib.util.*;
// import lib.graph.*;
// import lib.io.*;
// import lib.math.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        int[] alp = new int[26];
        for (int i = 0; i < N; i++) {
            alp[S[i] - 'a']++;
        }
        int res = 0;
        for (int i = 0; i < N; i++) {
            int[] tmp = alp.clone();
            int[] tmp2 = new int[26];
            for (int j = 0; j < i; j++) {
                tmp[S[j] - 'a']--;
                tmp2[S[j] - 'a']++;
            }
            int r = 0;
            for (int j = 0; j < 26; j++) {
                if (tmp[j] > 0 && tmp2[j] > 0) {
                    r++;
                }
            }
            res = Math.max(res, r);
        }
        out.println(res);

        out.flush();
    }
}

class UnionFindTree {
    int[] root;
    int[] rank;
    int[] size;
    int m;

    public UnionFindTree(int n) {
        this.root = new int[n];
        this.rank = new int[n];
        this.size = new int[n];
        this.m = n;
        for (int i = 0; i < n; i++) {
            root[i] = i;
            size[i] = 1;
        }
    }

    public int find(int x) {
        if (root[x] == x)
            return x;
        else {
            return root[x] = find(root[x]);
        }
    }

    public void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y]) {
            size[find(y)] = size[find(x)];
            root[x] = y;
        } else {
            size[find(x)] = size[find(y)];
            root[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        m--;
    }

    public boolean same(int x, int y) {
        return find(x) == find(y);
    }

    public int size(int i) {
        return this.size[find(i)];
    }
}

class Dijkstra {
    private static int prev[];
    private static long dist[];

    public Dijkstra(AbstractGraph graph, int s) {
        prev = new int[graph.n];
        dist = new long[graph.n];
        Arrays.fill(prev, -1);
        Arrays.fill(dist, Long.MAX_VALUE);
        PriorityQueue<Integer> searching = new PriorityQueue<>((x, y) -> Long.compare(dist[x], dist[y]));
        dist[s] = 0;
        searching.add(s);
        while (searching.size() > 0) {
            int now = searching.poll();
            for (Edge e : graph.getEdges(now)) {
                int next = e.to;
                long c = e.cost;
                if (dist[now] + c < dist[next]) {
                    dist[next] = dist[now] + c;
                    prev[next] = now;
                    searching.add(next);
                }
            }
        }
    }

    public int[] path(int to) {
        ArrayList<Integer> rev = new ArrayList<>();
        for (int now = to; now != -1; now = this.prev[now]) {
            rev.add(now);
        }
        int[] path = new int[rev.size()];
        for (int i = 0; i < path.length; i++) {
            path[i] = rev.get(path.length - i - 1);
        }
        return path;
    }
}

class WF {
    private static long[][] dist;

    public WF(AbstractGraph graph) {
        dist = new long[graph.n][graph.n];
        for (int i = 0; i < dist.length; i++) {
            Arrays.fill(dist[i], Integer.MAX_VALUE);
        }
        for (int i = 0; i < graph.n; i++) {
            for (Edge e : graph.getEdges(i)) {
                dist[i][e.to] = e.cost;
            }
            dist[i][i] = 0;
        }
        for (int k = 0; k < graph.n; k++) {
            for (int i = 0; i < graph.n; i++) {
                for (int j = 0; j < graph.n; j++) {
                    if (dist[i][k] != Integer.MAX_VALUE && dist[k][j] != Integer.MAX_VALUE) {
                        dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
                    }
                }
            }
        }
    }

    public static long getShortest(int s, int t) {
        return dist[s][t];
    }

    public static long[][] getAllDist() {
        return dist;
    }

    public static boolean isNegativeLoop() {
        for (int i = 0; i < dist.length; i++) {
            if (dist[i][i] < 0) {
                return true;
            }
        }
        return false;
    }
}

class Edge {
    int from, to;
    long cost;

    public Edge(int from, int to, long cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }

    public Edge(int from, int to) {
        this.from = from;
        this.to = to;
        this.cost = 1;
    }

    public Edge reverse() {
        return new Edge(to, from, cost);
    }
}

@SuppressWarnings("unchecked")
abstract class AbstractGraph {
    int n;
    int m;
    ArrayList<Edge>[] edges;

    public AbstractGraph(int n) {
        this.n = n;
        this.m = 0;
        this.edges = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            this.edges[i] = new ArrayList<Edge>();
        }
    }

    public void addEdge(Edge e) {
        this.m++;
        this.edges[e.from].add(e);
    }

    public int getV() {
        return this.n;
    }

    public int getE() {
        return this.m;
    }

    public ArrayList<Edge> getEdges(int v) {
        return this.edges[v];
    }

    abstract public boolean isBipartite();

    public boolean isTree() {
        // require Modifying.
        return false;
    }
}

class Graph extends AbstractGraph {
    int n;
    int m;
    // array of edges which is connect to the node
    ArrayList<Edge>[] edges;

    public Graph(int n) {
        super(n);
    }

    public void addEdge(int from, int to, int cost) {
        Edge e = new Edge(from, to, cost);
        super.addEdge(e);
        super.addEdge(e.reverse());
        this.m++;
    }

    @Override
    public void addEdge(Edge e) {
        this.edges[e.from].add(e);
        this.edges[e.to].add(e.reverse());
        this.m++;
    }

    public int getV(int v) {
        return n;
    }

    public int getE() {
        return m;
    }

    public boolean isBipartite() {
        int[] color = new int[n];
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        HashSet<Integer> visited = new HashSet<>();
        queue.add(0);
        color[0] = 1;
        while (queue.size() > 0) {
            int now = queue.poll();
            visited.add(now);
            for (Edge e : getEdges(now)) {
                if (visited.contains(e.to)) {
                    continue;
                }
                if (color[e.to] == color[now])
                    return false;
                queue.add(e.to);
                if (color[e.to] == 0)
                    color[e.to] = -1 * color[now];
            }
        }
        return true;
    }
}

class DirectedGraph extends AbstractGraph {
    int n;
    int m;
    // array of edges which is connect to the node
    ArrayList<Edge>[] edges;

    public DirectedGraph(int n) {
        super(n);
    }

    public void addEdge(int from, int to, int cost) {
        Edge e = new Edge(from, to, cost);
        super.addEdge(e);
        this.m++;
    }

    @Override
    public void addEdge(Edge e) {
        this.edges[e.from].add(e);
        this.m++;
    }

    public int getV(int v) {
        return this.n;
    }

    public int getE() {
        return this.m;
    }

    public boolean isBipartite() {
        // need to rewrite to work
        return false;
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class MyMath {
    public static long gcm(long a, long b) {

        // if (a < b)
        // return gcm(b, a);

        // if (b == 0 || a % b == 0)
        // return b;

        // return gcm(b, a % b);
        if (a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        long r = -1;
        while (r != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    public static long summation(long a, long b) {
        return b * (b + 1) / 2 - a * (a - 1) / 2;
    }

    public static long factorial(long n) {

        if (n <= 1)
            return 1;
        else
            return factorial(n - 1) * n;
    }

    public static long[][] binomialTable(int a, long m) {
        long[][] table = new long[a + 1][a + 1];
        for (int i = 0; i < a + 1; i++) {
            table[0][a] = 0;
            table[i][0] = 1;
            table[i][i] = 1;
        }
        for (int i = 1; i < a + 1; i++) {
            for (int j = 1; j < a + 1; j++) {
                if (i < j)
                    table[i][j] = 0;
                else {
                    table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % m;
                }
            }
        }
        return table;
    }

    public static long binomial(int n, int k, long m) {
        long res = 1;
        for (int l = n - k + 1; l <= n; l++) {
            res = (res % m) * (l % m) % m;
        }
        for (int r = 1; r <= k; r++) {
            res = (res % m) * modinv(r, m) % m;
        }
        return res;
    }

    public static long repeatSquarePow(long a, long n, long p) {
        if (n == 0)
            return 1;
        if (n == 1)
            return a % p;
        if (n % 2 == 1)
            return a * repeatSquarePow(a, n - 1, p) % p;
        long tmp = repeatSquarePow(a, n / 2, p) % p;
        return tmp * tmp % p;
    }

    public static long modinv(long a, long p) {
        long b, x, u, q, abs_p, tmp;
        abs_p = Math.abs(p);
        b = p;
        x = 1;
        u = 0;
        while (b > 0) {
            q = a / b;
            tmp = u;
            u = x - q * u;
            x = tmp;
            tmp = b;
            b = a - q * b;
            a = tmp;
        }
        return (x < 0) ? abs_p + x : x;
    }

    public static Long[] eratosthenes(int n) {
        Long[] factor_table = new Long[n];
        for (long i = 1; i <= n; i++) {
            factor_table[(int) (i - 1)] = i;
        }
        for (long i = 1; i <= n; i++) {
            if (factor_table[(int) (i - 1)] == i) {
                int j = 2;
                while (i * j <= n) {
                    factor_table[(int) (i * j - 1)] = i;
                    j++;
                }
            }
        }

        return factor_table;
    }

    public static HashMap<Long, Integer> primeFactorization(long n) {
        HashMap<Long, Integer> primes = new HashMap<>();
        for (long p = 2; p * p <= n; p++) {
            int q = 0;
            while (n % p == 0) {
                n /= p;
                q++;
            }
            if (q > 0)
                primes.put(p, q);
        }
        if (n > 1)
            primes.put(n, 1);
        return primes;
    }

    public static ArrayList<Integer> divisor(int n) {
        ArrayList<Integer> ret = new ArrayList<Integer>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                ret.add(i);
                // n=PQ+0→ PもQも約数. ただし、Q=Pは↑で登録済みなので登録しない
                if (i != n / i)
                    ret.add(n / i);
            }
        }
        return ret;
    }
}

class nextPermutation {
    public static int[] swap(int data[], int left, int right) {

        // Swap the data
        int temp = data[left];
        data[left] = data[right];
        data[right] = temp;

        // Return the updated array
        return data;
    }

    // Function to reverse the sub-array
    // starting from left to the right
    // both inclusive
    public static int[] reverse(int data[], int left, int right) {

        // Reverse the sub-array
        while (left < right) {
            int temp = data[left];
            data[left++] = data[right];
            data[right--] = temp;
        }

        // Return the updated array
        return data;
    }

    // Function to find the next permutation
    // of the given integer array
    public static boolean findNextPermutation(int data[]) {

        // If the given dataset is empty
        // or contains only one element
        // next_permutation is not possible
        if (data.length <= 1)
            return false;

        int last = data.length - 2;

        // find the longest non-increasing suffix
        // and find the pivot
        while (last >= 0) {
            if (data[last] < data[last + 1]) {
                break;
            }
            last--;
        }

        // If there is no increasing pair
        // there is no higher order permutation
        if (last < 0)
            return false;

        int nextGreater = data.length - 1;

        // Find the rightmost successor to the pivot
        for (int i = data.length - 1; i > last; i--) {
            if (data[i] > data[last]) {
                nextGreater = i;
                break;
            }
        }

        // Swap the successor and the pivot
        data = swap(data, nextGreater, last);

        // Reverse the suffix
        data = reverse(data, last + 1, data.length - 1);

        // Return true as the next_permutation is done
        return true;
    }
}

class ArrayUtil {
    private static long INF = 1_000_000_000_0L;

    public static int UpperBound(long[] array, long obj) {
        int l = 0, r = array.length - 1;
        while (r - l >= 0) {
            int c = (l + r) / 2;
            if (obj < array[c]) {
                r = c - 1;
            } else {
                l = c + 1;
            }
        }
        return l;
    }

    public static int LowerBound(long[] array, long obj) {
        int l = 0, r = array.length - 1;
        while (r - l >= 0) {
            int c = (l + r) / 2;
            if (obj <= array[c]) {
                r = c - 1;
            } else {
                l = c + 1;
            }
        }
        return l;
    }

    // return the length of array's LIS
    public static int LIS(long[] array) {
        long[] dp = new long[array.length + 1];
        Arrays.fill(dp, INF);
        for (int i = 0; i < array.length; i++) {
            int idx = LowerBound(dp, array[i]);
            dp[idx] = array[i];
        }
        return LowerBound(dp, INF - 1);
    }

    public static int StrictLIS(long[] array) {
        long[] dp = new long[array.length + 1];
        Arrays.fill(dp, INF);
        for (int i = 0; i < array.length; i++) {
            int idx = UpperBound(dp, array[i]);
            dp[idx] = array[i];
        }
        return UpperBound(dp, INF - 1);
    }
}

class BinaryIndexedTree {
    int[] data;
    long[] tree;
    int n;

    public BinaryIndexedTree(int[] data) {
        this.data = data;
        this.n = data.length;
        this.tree = new long[n + 1];
        buildTree();
    }

    public void buildTree() {
        for (int i = 0; i < n; i++) {
            add(i + 1, data[i]);
        }
    }

    public void add(int index, int value) {
        for (int i = index; i <= n; i += i & -i) {
            tree[i] += value;
        }
    }

    public long sum(int from, int to) {
        return sum(to) - sum(from - 1);
    }

    public long sum(int index) {
        int sum = 0;
        for (int i = index; i > 0; i -= i & -i) {
            sum += tree[i];
        }
        return sum;
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	private void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int ans = 0;
		for (int sp = 0; sp < N; sp++) {
			int[] count = new int[26];
			for (int i = 0; i < N; i++) {
				if (i <= sp) {
					count[S.charAt(i) - 'a'] = 1;
				} else if (count[S.charAt(i) - 'a'] == 1) {
					count[S.charAt(i) - 'a'] = 2;
				}
			}
			int tmp = 0;
			for (int i = 0; i < 26; i++) {
				if (count[i] == 2) {
					tmp++;
				}
			}
			if (ans < tmp) {
				ans = tmp;
			}
		}
		System.out.println(ans);
	}

	class Scanner {
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int index;
		private int length;

		public Scanner(InputStream in) {
			this.in = in;
		}

		private boolean isPrintableChar(int c) {
			return '!' <= c && c <= '~';
		}

		private boolean isDigit(int c) {
			return '0' <= c && c <= '9';
		}

		private boolean hasNextByte() {
			if (index < length) {
				return true;
			} else {
				try {
					length = in.read(buffer);
					index = 0;
				} catch (IOException e) {
					e.printStackTrace();
				}
				return length > 0;
			}
		}

		private boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[index])) {
				index++;
			}
			return hasNextByte();
		}

		private int readByte() {
			return hasNextByte() ? buffer[index++] : -1;
		}

		public String next() {
			if (!hasNext()) {
				throw new RuntimeException("no input");
			}
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) {
				throw new RuntimeException("no input");
			}
			long value = 0L;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			while (isPrintableChar(b)) {
				if (isDigit(b)) {
					value = value * 10 + (b - '0');
				}
				b = readByte();
			}
			return minus ? -value : value;
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	interface CombCalculator {
		long comb(int n, int m);
	}

	interface MobiusFunction {
		int get(int n);
	}

	/**
	 * メビウス関数をエラトステネスの篩っぽく前計算するクラスです。
	 * 計算量はO(1)で、前計算でO(N logN)です。
	 */
	class SieveMobiusFunction implements MobiusFunction {
		int size;
		int[] mobiusFunctionValues;

		public SieveMobiusFunction(int size) {
			this.size = size;
			mobiusFunctionValues = new int[size];

			mobiusFunctionValues[0] = 0;
			mobiusFunctionValues[1] = 1;
			for (int i = 2; i < size; i++) {
				mobiusFunctionValues[i] = 1;
			}
			for (int i = 2; i * i < size; i++) {
				for (int k = 1; i * i * k < size; k++) {
					mobiusFunctionValues[i * i * k] *= 0;
				}
			}

			for (int i = 2; i < size; i++) {
				if (mobiusFunctionValues[i] == 1) {
					for (int k = 1; i * k < size; k++) {
						mobiusFunctionValues[i * k] *= -2;
					}
				}
				if (mobiusFunctionValues[i] > 1) {
					mobiusFunctionValues[i] = 1;
				}
				if (mobiusFunctionValues[i] < -1) {
					mobiusFunctionValues[i] = -1;
				}
			}
		}

		@Override
		public int get(int n) {
			if (n > size) {
				throw new RuntimeException("n is greater than size.");
			}
			if (n < 0) {
				return 0;
			}
			return mobiusFunctionValues[n];
		}
	}

	/**
	 * メビウス関数を定義通り計算するクラスです。
	 * 計算量はO(logN)です。
	 */
	class PrimeFactorizationMobiusFunction implements MobiusFunction {
		@Override
		public int get(int n) {
			if (n <= 0) {
				return 0;
			}
			if (n == 1) {
				return 1;
			}
			int num = 0;
			for (int i = 2; i < n; i++) {
				if (n % i == 0) {
					n /= i;
					num++;
					if (n % i == 0) {
						return 0;
					}
				}
			}
			return num % 2 == 0 ? -1 : 1;
		}
	}

	/**
	 * 組み合わせ計算を階乗の値で行うクラスです(MOD対応)
	 * 階乗とその逆元は前計算してテーブルに格納します。
	 * C(N, N) % M の計算量は O(1)、 前計算でO(max(N, logM))です。
	 * sizeを1e8より大きい値で実行するとMLEの危険性があります。
	 * また素数以外のMODには対応していません(逆元の計算に素数の剰余環の性質を利用しているため)。
	 */
	class FactorialTableCombCalculator implements CombCalculator {
		int size;
		long[] factorialTable;
		long[] inverseFactorialTable;
		long mod;

		public FactorialTableCombCalculator(int size, long mod) {
			this.size = size;
			factorialTable = new long[size + 1];
			inverseFactorialTable = new long[size + 1];
			this.mod = mod;

			factorialTable[0] = 1L;
			for (int i = 1; i <= size; i++) {
				factorialTable[i] = (factorialTable[i - 1] * i) % mod;
			}
			inverseFactorialTable[size] = inverse(factorialTable[size], mod);
			for (int i = size - 1; i >= 0; i--) {
				inverseFactorialTable[i] = (inverseFactorialTable[i + 1] * (i + 1)) % mod;
			}
		}

		private long inverse(long n, long mod) {
			return pow(n, mod - 2, mod);
		}

		private long pow(long n, long p, long mod) {
			if (p == 0) {
				return 1L;
			}
			long half = pow(n, p / 2, mod);
			long ret = (half * half) % mod;
			if (p % 2 == 1) {
				ret = (ret * n) % mod;
			}
			return ret;
		}

		@Override
		public long comb(int n, int m) {
			if (n > size) {
				throw new RuntimeException("n is greater than size.");
			}
			if (n < 0 || m < 0 || n < m) {
				return 0L;
			}
			return (((factorialTable[n] * inverseFactorialTable[m]) % mod) * inverseFactorialTable[n - m]) % mod;
		}
	}

	/**
	 * 組み合わせ計算をテーブルで実装したクラスです(MOD対応)
	 * 前計算でO(N^2), combはO(1)で実行できます
	 * sizeを2 * 1e4より大きい値で実行するとMLEの危険性があります
	 */
	class TableCombCalculator implements CombCalculator {
		long[][] table;
		int size;

		public TableCombCalculator(int size, long mod) {
			this.size = size;
			table = new long[size + 1][];

			table[0] = new long[1];
			table[0][0] = 1L;
			for (int n = 1; n <= size; n++) {
				table[n] = new long[n + 1];
				table[n][0] = 1L;
				for (int m = 1; m < n; m++) {
					table[n][m] = (table[n - 1][m - 1] + table[n - 1][m]) % mod;
				}
				table[n][n] = 1L;
			}
		}

		@Override
		public long comb(int n, int m) {
			if (n > size) {
				throw new RuntimeException("n is greater than size.");
			}
			if (n < 0 || m < 0 || n < m) {
				return 0L;
			}
			return table[n][m];
		}
	}

	interface Graph {
		void link(int from, int to, long cost);
		Optional<Long> getCost(int from, int to);
		int getVertexNum();
	}

	interface FlowResolver {
		long maxFlow(int from, int to);
	}

	/**
	 * グラフの行列による実装
	 * 接点数の大きいグラフで使うとMLEで死にそう
	 */
	class ArrayGraph implements Graph {
		private Long[][] costArray;
		private int vertexNum;

		public ArrayGraph(int n) {
			costArray = new Long[n][];
			for (int i = 0; i < n; i++) {
				costArray[i] = new Long[n];
			}
			vertexNum = n;
		}

		@Override
		public void link(int from, int to, long cost) {
			costArray[from][to] = new Long(cost);
		}

		@Override
		public Optional<Long> getCost(int from, int to) {
			return Optional.ofNullable(costArray[from][to]);
		}

		@Override
		public int getVertexNum() {
			return vertexNum;
		}
	}

	/**
	 * DFS(深さ優先探索)による実装
	 * 計算量はO(E*MaxFlow)のはず (E:辺の数, MaxFlow:最大フロー)
	 */
	class DfsFlowResolver implements FlowResolver {
		private Graph graph;
		public DfsFlowResolver(Graph graph) {
			this.graph = graph;
		}

		/**
		 * 最大フロー(最小カット)を求める
		 * @param from 始点(source)のID
		 * @param to 終点(target)のID
		 * @return 最大フロー(最小カット)
		 */
		public long maxFlow(int from, int to) {
			long sum = 0L;
			long currentFlow;
			do {
				currentFlow = flow(from, to, Long.MAX_VALUE / 3, new boolean[graph.getVertexNum()]);
				sum += currentFlow;
			} while (currentFlow > 0);
			return sum;
		}

		/**
		 * フローの実行 グラフの更新も行う
		 * @param from 現在いる節点のID
		 * @param to 終点(target)のID
		 * @param current_flow ここまでの流量
		 * @param passed 既に通った節点か否かを格納した配列
		 * @return 終点(target)に流した流量/戻りのグラフの流量
		 */
		private long flow(int from, int to, long current_flow, boolean[] passed) {
			passed[from] = true;
			if (from == to) {
				return current_flow;
			}
			for (int id = 0; id < graph.getVertexNum(); id++) {
				if (passed[id]) {
					continue;
				}
				Optional<Long> cost = graph.getCost(from, id);
				if (cost.orElse(0L) > 0) {
					long nextFlow = current_flow < cost.get() ? current_flow : cost.get();
					long returnFlow = flow(id, to, nextFlow, passed);
					if (returnFlow > 0) {
						graph.link(from, id, cost.get() - returnFlow);
						graph.link(id, from, graph.getCost(id, from).orElse(0L) + returnFlow);
						return returnFlow;
					}
				}
			}
			return 0L;
		}
	}

	/**
	 * 1-indexedのBIT配列
	 */
	class BinaryIndexedTree {
		private long[] array;

		public BinaryIndexedTree(int size) {
			this.array = new long[size + 1];
		}

		/**
		 * 指定した要素に値を加算する
		 * 計算量はO(logN)
		 * @param index 加算する要素の添字
		 * @param value 加算する量
		 */
		public void add(int index, long value) {
			for (int i = index; i < array.length; i += (i & -i)) {
				array[i] += value;
			}
		}

		/**
		 * 1〜指定した要素までの和を取得する
		 * 計算量はO(logN)
		 * @param index 和の終端となる要素の添字
		 * @return 1〜indexまでの和
		 */
		public long getSum(int index) {
			long sum = 0L;
			for (int i = index; i > 0; i -= (i & -i)) {
				sum += array[i];
			}
			return sum;
		}
	}

	/**
	 * 1-indexedの2次元BIT配列
	 */
	class BinaryIndexedTree2D {
		private long[][] array;

		public BinaryIndexedTree2D(int size1, int size2) {
			this.array = new long[size1 + 1][];
			for (int i = 1; i <= size1; i++) {
				this.array[i] = new long[size2 + 1];
			}
		}

		/**
		 * 指定した要素に値を加算する
		 * 計算量はO(logN * logN)
		 * @param index1 加算する要素の1次元目の添字
		 * @param index2 加算する要素の2次元目の添字
		 * @param value 加算する量
		 */
		public void add(int index1, int index2, long value) {
			for (int i1 = index1; i1 < array.length; i1 += (i1 & -i1)) {
				for (int i2 = index2; i2 < array.length; i2 += (i2 & -i2)) {
					array[i1][i2] += value;
				}
			}
		}

		/**
		 * (1,1)〜指定した要素までの矩形和を取得する
		 * 計算量はO(logN * logN)
		 * @param index1 和の終端となる要素の1次元目の添字
		 * @param index2 和の終端となる要素の2次元目の添字
		 * @return (1,1)〜(index1,index2)までの矩形和
		 */
		public long getSum(int index1, int index2) {
			long sum = 0L;
			for (int i1 = index1; i1 > 0; i1 -= (i1 & -i1)) {
				for (int i2 = index2; i2 > 0; i2 -= (i2 & -i2)) {
					sum += array[i1][i2];
				}
			}
			return sum;
		}
	}

	interface UnionFind {
		void union(int A, int B);
		boolean judge(int A, int B);
		Set<Integer> getSet(int id);
	}

	/**
	 * ArrayUnionFindの拡張
	 * MapSetで根の添字から根にぶら下がる頂点の集合が取得できるようにした
	 * getSetメソッドをO(logN * logN)に落とせているはず
	 * ただしunionメソッドは2倍の計算量になっているので注意(オーダーは変わらないはず)
	 */
	class SetUnionFind extends ArrayUnionFind {
		Map<Integer, Set<Integer>> map;
		public SetUnionFind(int size) {
			super(size);
			map = new HashMap<>();
			for (int i = 0; i < size; i++) {
				map.put(i, new HashSet<>());
				map.get(i).add(i);
			}
		}

		@Override
		protected void unionTo(int source, int dest) {
			super.unionTo(source, dest);
			map.get(dest).addAll(map.get(source));
		}

		@Override
		public Set<Integer> getSet(int id) {
			return map.get(root(id));
		}
	}

	/**
	 * 配列によるUnionFindの実装
	 * getSetメソッドはO(NlogN)なのでTLEに注意
	 */
	class ArrayUnionFind implements UnionFind {
		int[] parent;
		int[] rank;
		int size;
		public ArrayUnionFind(int size) {
			parent = new int[size];
			for (int i = 0; i < size; i++) {
				parent[i] = i;
			}
			rank = new int[size];
			this.size = size;
		}

		@Override
		public void union(int A, int B) {
			int rootA = root(A);
			int rootB = root(B);
			if (rootA != rootB) {
				if (rank[rootA] < rank[rootB]) {
					unionTo(rootA, rootB);
				} else {
					unionTo(rootB, rootA);
					if (rank[rootA] == rank[rootB]) {
						rank[rootA]++;
					}
				}
			}
		}

		protected void unionTo(int source, int dest) {
			parent[source] = dest;
		}

		@Override
		public boolean judge(int A, int B) {
			return root(A) == root(B);
		}

		@Override
		public Set<Integer> getSet(int id) {
			Set<Integer> set = new HashSet<>();
			IntStream.range(0, size).filter(i -> judge(i, id)).forEach(set::add);
			return set;
		}

		protected int root(int id) {
			if (parent[id] == id) {
				return id;
			}
			parent[id] = root(parent[id]);
			return parent[id];
		}
	}

	/**
	 * 素数のユーティリティ
	 */
	class PrimeNumberUtils {
		boolean[] isPrimeArray;
		List<Integer> primes;

		/**
		 * 素数判定の上限となる値を指定してユーティリティを初期化
		 * @param limit 素数判定の上限(この値以上が素数であるか判定しない)
		 */
		public PrimeNumberUtils(int limit) {
			if (limit > 10000000) {
				System.err.println("上限の値が高すぎるため素数ユーティリティの初期化でTLEする可能性が大変高いです");
			}
			primes = new ArrayList<>();
			isPrimeArray = new boolean[limit];
			if (limit > 2) {
				primes.add(2);
				isPrimeArray[2] = true;
			}

			for (int i = 3; i < limit; i += 2) {
				if (isPrime(i, primes)) {
					primes.add(i);
					isPrimeArray[i] = true;
				}
			}
		}

		public List<Integer> getPrimeNumberList() {
			return primes;
		}

		public boolean isPrime(int n) {
			return isPrimeArray[n];
		}

		private boolean isPrime(int n, List<Integer> primes) {
			for (int prime : primes) {
				if (n % prime == 0) {
					return false;
				}
				if (prime > Math.sqrt(n)) {
					break;
				}
			}
			return true;
		}
	}

	interface BitSet {
		void set(int index, boolean bit);
		boolean get(int index);
		void shiftRight(int num);
		void shiftLeft(int num);
		void or(BitSet bitset);
		void and(BitSet bitset);
	}

	/**
	 * Longの配列によるBitSetの実装
	 * get/setはO(1)
	 * shift/or/andはO(size / 64)
	 */
	class LongBit implements BitSet {
		long[] bitArray;

		public LongBit(int size) {
			bitArray = new long[((size + 63) / 64)];
		}

		@Override
		public void set(int index, boolean bit) {
			int segment = index / 64;
			int inIndex = index % 64;
			if (bit) {
				bitArray[segment] |= 1L << inIndex;
			} else {
				bitArray[segment] &= ~(1L << inIndex);
			}
		}

		@Override
		public boolean get(int index) {
			int segment = index / 64;
			int inIndex = index % 64;
			return (bitArray[segment] & (1L << inIndex)) != 0L;
		}

		@Override
		public void shiftRight(int num) {
			int shiftSeg = num / 64;
			int shiftInI = num % 64;
			for (int segment = 0; segment < bitArray.length; segment++) {
				int sourceSeg = segment + shiftSeg;
				if (sourceSeg < bitArray.length) {
					bitArray[segment] = bitArray[sourceSeg] >>> shiftInI;
					if (shiftInI > 0 && sourceSeg + 1 < bitArray.length) {
						bitArray[segment] |= bitArray[sourceSeg + 1] << (64 - shiftInI);
					}
				} else {
					bitArray[segment] = 0L;
				}
			}
		}

		@Override
		public void shiftLeft(int num) {
			int shiftSeg = num / 64;
			int shiftInI = num % 64;
			for (int segment = bitArray.length - 1; segment >= 0; segment--) {
				int sourceSeg = segment - shiftSeg;
				if (sourceSeg >= 0) {
					bitArray[segment] = bitArray[sourceSeg] << shiftInI;
					if (shiftInI > 0 && sourceSeg > 0) {
						bitArray[segment] |= bitArray[sourceSeg - 1] >>> (64 - shiftInI);
					}
				} else {
					bitArray[segment] = 0L;
				}
			}
		}

		public long getLong(int segment) {
			return bitArray[segment];
		}

		@Override
		public String toString() {
			StringBuilder sb = new StringBuilder();
			for (int i = bitArray.length - 1; i >= 0; i--) {
				sb.append(String.format("%64s", Long.toBinaryString(bitArray[i])).replace(' ', '0'));
			}
			return sb.toString();
		}

		@Override
		public void or(BitSet bitset) {
			if (!(bitset instanceof LongBit)) {
				return;
			}
			for (int segment = 0; segment < bitArray.length; segment++) {
				bitArray[segment] |= ((LongBit)bitset).getLong(segment);
			}
		}

		public void xor(BitSet bitset) {
			if (!(bitset instanceof LongBit)) {
				return;
			}
			for (int segment = 0; segment < bitArray.length; segment++) {
				bitArray[segment] ^= ((LongBit)bitset).getLong(segment);
			}
		}

		@Override
		public void and(BitSet bitset) {
			if (!(bitset instanceof LongBit)) {
				return;
			}
			for (int segment = 0; segment < bitArray.length; segment++) {
				bitArray[segment] &= ((LongBit)bitset).getLong(segment);
			}
		}
	}

}


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


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


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

    }
}


#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;
}


#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;
}


#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;
}


#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;
}


#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;
}


#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;
}


#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);
}


#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;
}


#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;
}


#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;
  }
}


#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;
}


#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;
}


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


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


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


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


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