import           Control.Monad
import           Control.Applicative
import           Data.Ord
import           Data.List
import qualified Data.Vector                   as V
import           Data.Array.IO

main :: IO ()
main = do
  s <- group . sort <$> getLine

  print $ if length s == 1 then 0 else 2 * (minimum . map length) s