{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ i, o, _, j, l, _, _ ] :: [ Integer ] <- map read . words <$> getLine
	print $ o + solve i j l

solve i j l
	| 0 < mi = mi * 3 + solve ( i - mi ) ( j - mi ) ( l - mi )
	| otherwise = d i + d j + d l
	where
		mi = minimum [ i, j, l ]
		d = ( * 2 ) . ( `div` 2 )

