main :: IO ()
main = do
  sss <- getContents
  let s = map (map strToInt) $ map (splitBy ',') $ lines sss
      ans = foldl1 makeNex s
  putStrLn (show (head ans))
splitBy :: Char -> String -> [String]
splitBy c l = foldr f [[]] l
                where f x acc
                        | x == c = []:acc
                        | otherwise = (x : (head acc)) : (tail acc)

strToInt :: String -> Int
strToInt str = read str

makeNex :: [Int] -> [Int] -> [Int]
makeNex y x = if (length x) > (length y)
                then zipWith (+) x (makeNex2 (0:y)++[0])
                else zipWith (+) x (makeNex2 y)

makeNex2 (_:[]) = []
makeNex2 (y1:y2:ys) = (max y1 y2) : (makeNex2 (y2:ys))