#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define fr first
#define sc second
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

vector<int> split(string s){
    int x = -1;
    vector<int> ret;
    s += ",";
    REP(i,s.size()){
	if(s[i] == ','){
	    ret.PB(stoi(s.substr(x+1,i-x-1)));
	    x = i;
	}
    }
    return ret;
}

int main(){
    vector< vector<int> > m;
    int count = 1;
    int dp[100][100];
    memset(dp,0,sizeof(dp));
    while(true){
	string s;
	cin >> s;
	if(cin.eof()){
	    break;
	}
	m.PB(split(s));
	if(s.size() == 1) count--;
	if(count == -1) break;
    }
    vector< vector<int> > h;
    vector< vector<int> > t;

    dp[0][0] = m[0][0];
    REP(i,m.size()/2){
	REP(j,m[i].size()){
	    dp[i+1][j] = max(dp[i+1][j] , dp[i][j] + m[i+1][j]);
	    dp[i+1][j+1] = max(dp[i+1][j+1] , dp[i][j] + m[i+1][j+1]);
	}
    }
    FOR(i,m.size()/2,m.size()-1){
	REP(j,m[i+1].size()){
	    dp[i+1][j] = max(dp[i+1][j] , dp[i][j] + m[i+1][j]);
	    dp[i+1][j] = max(dp[i+1][j] , dp[i][j+1] + m[i+1][j]);
	}
    }
    cout << dp[m.size()-1][0] << endl;

    return 0;
}