import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] ch = str.toCharArray();
        HashSet<Character> set = new HashSet<>();
        for(int i=0;i<ch.length;i++){
            set.add(ch[i]);
        }
        if(set.size()==1){
            System.out.println("1");
        }else if (set.size()==2){
            System.out.println("2");
        } else {
            System.out.println("0");
        }

    }
}