def runlegth(S): cnt = 1 d = [] for i in range(len(S)-1): if S[i] == S[i+1]: cnt += 1 else: d.append(cnt) cnt = 1 d.append(cnt) return d def main(): S = input() D = runlegth(S) first = 0 second = 0 ans = 0 for i in range(len(D)): if i % 2 == 0: first += D[i] ans = max(ans, min(first,second)) if D[i] >= second: second = 0 else: second += D[i] ans = max(ans, min(first,second)) if D[i] >= first: first = 0 print(ans * 2) if __name__ == "__main__": main()