import Data.List

solve :: (Int, Int, Int) -> Int
solve (a,b,c) 
    | c - b == 1 = 1 + solve (a+1,c,c)
    | c - b > 0 && even (c-b) = (c-b) `quot` 2 + solve (a,c,c) 
    | c - b >= 3 = 1 + solve (a+1,b+1,c)
    | c == b && even (b-a) = (b-a) `quot` 2
    | c == b && odd (b-a) = 1 + solve (a,b+1,c+1)

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