#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){

	string in;
	string tmp;
	int cal;
	int cnt=0;
	vector<int> sq[100];

	while(cin>>in){
		cnt++;
		for(int i=0;i<=in.size();i++){
			if(i==in.size()||in[i]==','){
				if(tmp.size()==1) cal=tmp[0]-'0';
				else cal=tmp[1]-'0'+10*(tmp[0]-'0');
				sq[cnt-1].push_back(cal);
				tmp="";
			}
			else{
				tmp+=in[i];
			}
		}
	}

	for(int i=1;i<cnt;i++){
		for(int j=0;j<sq[i].size();j++){
			if(cnt/2+1>i){
				if(j==0){
					sq[i][j]+=sq[i-1][j];
				}
				else if(j==sq[i].size()-1){
					sq[i][j]+=sq[i-1][j-1];
				}
				else{
					sq[i][j]+=max(sq[i-1][j],sq[i-1][j-1]);
				}
			}
			else{
				sq[i][j]+=max(sq[i-1][j],sq[i-1][j+1]);
			}
		}
	}

	cout<<sq[cnt-1][0]<<endl;
}