#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string nes,niz="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int brojac=1;
    cin >> nes;
    if(nes.size()<26){
        cout << 0 << endl;
    }
    if(nes.size()==26){
        if(nes=="ABCDEFGHIJKLMNOPQRSTUVWXYZ"){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    if(nes.size()==27){
        for(int j=0;j<26;j++){
            if(nes[j]!=niz[j]){
                if(j>=1){
                    if(nes[j]==nes[j-1]){
                        brojac++;
                    }
                    nes.erase(j,1);
                    if(nes==niz){
                        if(brojac==2){
                            cout << 2 << endl;
                            return 0;
                        }
                        cout << 1 << endl;
                        return 0;
                    }
                    else{
                        cout << 0 << endl;
                        return 0;
                    }
                }

            }
        }
        if(nes[25]==nes[26]){
            cout << 2 << endl;
            return 0;
        }
        cout << 1 << endl;
    }
    return 0;
}