import Data.List

func [a,b,c]
 |even a == even b && even b == even c = [a,b,c,0]
 |even a == even b = [a+1,b+1,c  ,1]
 |even a == even c = [a+1,b  ,c+1,1]
 |even b == even c = [a  ,b+1,c+1,1]

main = do
 list <- map read . words <$> getLine
 let [a,b,c,d] = func list
     largest = maximum [a,b,c]
 print $ d+abs (largest-a) `div` 2 + abs (largest-b) `div` 2 + abs (largest-c) `div` 2