import Control.Monad
import Control.Applicative
import Data.List



main :: IO()
main = do
  str <- getLine
  let num = (minimum . countBySame') str
  let ans = if length str == 1
              then 0
              else num * 2
  print ans



countBySame' :: (Ord a) => [a] -> [Int]
countBySame' [] = []
countBySame' lst = let x:xs = sort lst  ; (n, list) = (samelist x xs 0) in n : (countBySame' list)
  where
    samelist ::(Ord a) => a -> [a] ->  Int -> (Int, [a])
    samelist a [] n = (n+1, [])
    samelist a (x:xs) n
                  | a == x = samelist a xs (n+1)
                  | a /= x = (n+1, x:xs)
