ary = gets.chomp.split('').map(&:to_i)

def max_deletion (ary)
  if ary.length < 2
    return 0
  elsif ary.length == 2
    if ary[0] != ary[1]
      return 2
    else
      return 0
    end
  end
  max = 0
  0.upto(ary.length-2).each do |i|
    if ary[i] != ary[i+1]
      new_ary = ary.dup
      new_ary.slice!(i, 2)
      #print("#{new_ary}\n")
      val = 2 + max_deletion(new_ary)
      if max < val
        max = val
      end
    end
  end
  max
end

ans = max_deletion(ary)

print("#{ans}\n")