{-# LANGUAGE BangPatterns #-}
import Data.List

main :: IO ()
main = do
  [a,b,c] <- map read . words <$> getLine
  print $ solve a b c

solve :: Int -> Int -> Int -> Int
solve a b c = go 0 [(T a b c)]
  where
    go !n ts | any ok ts = n
             | otherwise = go (n+1) $ concatMap next ts

data T = T !Int !Int !Int

ok :: T -> Bool
ok (T a b c) = a == b && b == c

next :: T -> [T]
next (T a b c) = [ T (x+1) (y+1) z
                 , T (x+2) y z
                 ]
  where [x,y,z] = sort [a,b,c]
