#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    cnt = 0
    flag = False
    ok = False
    while True:
        if flag:
            break
        i = 0
        while i < len(s)-1:
            ok = False
            if s[i] != s[i+1]: # 違うものが出た
                cnt += 2
                s = (s[:i] + s[i+2:] if len(s) >= 3 else s[:i])
                ok = True
                break
            i += 1
        if not ok:
            break
        if len(s) == 0:
            break
    print(cnt)


if __name__ == '__main__':
  main()
