#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
int dp[100][100];

int main (){
	string tmp;
	vector<vector<int> > data;
	for(int i=0; i<100; ++i){
		for(int j=0; j<100; ++j){
			dp[i][j]=-1;
		}
	}
	while(cin >> tmp){
		vector<int> v;
		replace(tmp.begin(),tmp.end(),',',' ');
		stringstream ss(tmp);

		while(ss >> tmp){
			v.push_back(atoi(tmp.c_str()));
		}
		data.push_back(v);
	}
	dp[0][0]=data[0][0];
	for(int i=1; i<data.size(); ++i){
		for(int j=0; j<data[i].size(); ++j){
			for(int k=0; k<data[i-1].size(); ++k){
				if(i<=data.size()/2){
					if(k==j||k+1==j){
						dp[i][j]=max(dp[i][j],dp[i-1][k]+data[i][j]);
					}
				} else {
					if(k==j||k-1==j){
						 dp[i][j]=max(dp[i][j],dp[i-1][k]+data[i][j]);
					}
				}
			}
		}
	}
	//cout << dp[1][0] << " " << dp[1][1] << "\n";
	cout << dp[data.size()-1][0] << "\n";
	/*for(int i=0; i<data.size(); ++i){
		for(int j=0; j<data[i].size(); ++j){
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}*/
	return 0;
}