import Data.List
import qualified Data.Set as S

main = do
    [a,b,c] <- sort.map read.words<$>getLine :: IO [Int]
    print $ sol 0 [[a,b,c]]

sol n as =
    case findIndex (\[a,b,c] -> a==b && b==c) as of
        Just _ -> n
        Nothing ->
            sol (n+1) nas
            where
                nas = S.toList $ S.fromList ops
                ops = concatMap (\[a,b,c] -> [sort [a+1,b+1,c], sort [a+2,b,c]]) as

