def dp(st):
    ref = ""
    count = 0
    pos = []
    ans = []
    for n,s in enumerate(st):
        if ref=="":
            ref = s
        else:
            if ref != s:
                pos.append(n-1)
            else:
                count = 0
            ref = s
    # print(pos)
    if pos:
        for p in pos:
            ans.append(dp(st[:p]+st[p+2:])+1)
    else:
        return 0
    return max(ans)



s = input()
ans = dp(s)
print(ans*2)