s = input()
length=len(s)
l = int(len(s)/2)
def erase_01_10(moji):
  moji = moji.replace('01','').replace('0011','').replace('000111','')
  moji = moji.replace('10','').replace('1100','').replace('111000','')
  return moji
for i in range(l):
  if s == erase_01_10(s):
    break
  s = erase_01_10(s)
print(length-len(s))
