#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n = 0;
    vector<vector<int> > num;
    string s;
    while(cin >> s){
        num.resize(n + 1);
        istringstream iss(s);
        for(;;){
            int a;
            iss >> a;
            num[n].push_back(a);
            char c;
            if(!(iss >> c))
                break;
        }
        ++ n;
    }

    vector<vector<int> > dp(n, vector<int>((n+1)/2, 0));
    dp[0][0] = num[0][0];
    for(int i=0; i<n/2; ++i){
        for(int j=0; j<=i; ++j){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + num[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + num[i+1][j+1]);
        }
    }
    for(int i=n/2+1; i<n; ++i){
        for(int j=0; j<n-i; ++j){
            dp[i][j] = max(dp[i][j], dp[i-1][j] + num[i][j]);
            dp[i][j] = max(dp[i][j], dp[i-1][j+1] + num[i][j]);
        }
    }

    cout << dp[n-1][0] << endl;

    return 0;
}