#include <iostream>
using namespace std;

const long long c = 1000000007;

int main(){
    
    int n;
    string s;
    cin >> n >> s;
    
    if(n < 26)
        cout << 0 << endl;
    
    int p1[26];
    
    for(int i = 0; i < n; i++)
        p1[s[i] - 'A']++;
    
    bool b;
    
    for(int i = 0; i < 26; i++)
        if(p1[i] == 0)
            b = true;
    
    if(b){
        cout << 0 << endl;
        return 0;
    }
    
    for(int i = 1; i < n; i++)
        if(s[i] == s[i - 1])
            b = true;
    
    if(b)
        cout << 2 << endl;
    else cout << 1 << endl;
    
    
    return 0;
}