#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>

using namespace std;

int f[99][50];
int dp[99][50];
bool debug = true;

int main(void){
	string str;
	int i=0,j=0,tmp;
	
	while(getline(cin,str)){
		istringstream iss(str);
		
		j=0;
		while(iss >> tmp){
			iss.ignore();
			f[i][j] = tmp;
			//if(debug) printf("f[%d][%d] = %d\n",i,j,f[i][j]);
			j++;
		}
		i++;
	}
	
	int row = i-1;
	dp[0][0] = f[0][0]; //dp[i][j] := maximal number of i-th row's j-th column
	for(int i=1;i<=row/2;i++){ //upeer half
		for(int j=0;j<=i;j++){
			if(j==0){
				dp[i][j] = f[i][j] + dp[i-1][j];
			}else if(j==i){
				dp[i][j] = f[i][j] + dp[i-1][j-1];
			}else{
				dp[i][j] = f[i][j] + max(dp[i-1][j-1], dp[i-1][j]);
			}
		}
	}
	for(int i=row/2+1;i<=row;i++){ //lower half
		for(int j=0;j<=row-i;j++){
			dp[i][j] = f[i][j] + max(dp[i-1][j], dp[i-1][j+1]);
		}
	}
	
	cout << dp[row][0] << endl;
}