s = list(str(input()))
def caisezhuangkuai(s):
    a = len(s)
    num = len(set(s))
    if num==2:
        return 2
    elif num==1:
        return 1
    else:
        return 0
print(caisezhuangkuai(s))