def m(s, current)
  return current if s.size < 2

  results = (0..s.size-2).map do |i|
    if s[i] != s[i+1]
      ss = s.dup
      ss.delete_at(i)
      ss.delete_at(i)
      m(ss, current + 2)
    else
      current
    end
  end
  results.max
end

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

puts m(s, 0)
