#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

int dp[100][100];

int main(void){
string ws,wk;
int dm[101][52]={0};
int lw=0,cl,mcl=0;;
	while(getline(cin,ws)){
		replace(ws.begin(),ws.end(),',',' ');
		stringstream zz(ws);
		cl = 0;
		while( zz >> dm[lw][cl] ){
			cl++;
			mcl=max(cl,mcl);
		}
		lw++;
		if(cl== 1 && lw > 2 ) break;
	}

	rep(i, lw){
		rep(j, i+1){
			if(i <= lw/2){
				if(i == 0) dp[i][j] = dm[i][j]; 
				else if(j == 0)dp[i][j] = dp[i-1][j] + dm[i][j];
				else dp[i][j] = max(dp[i-1][j] + dm[i][j],
						dp[i-1][j-1] + dm[i][j]);
      		}else{
				dp[i][j] = max(dp[i-1][j] + dm[i][j],dp[i-1][j+1] + dm[i][j]);
      		}
    	} 
  	}
	cout << dp[lw-1][0] << endl;
//	rep(i,mcl) printf("%d, ",dp[lw-1][i]);
	return 0;
	
}