#include <iostream>
#include <string>
#include <vector>
using namespace std;

int s_to_i(string s){
	int n=0;
	for(int i=0 ; i<(int)s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

vector<int> vs_to_vi(vector<string> vs){
	vector<int> vi;
	for(int i=0 ; i<(int)vs.size() ; i++ ){
		vi.push_back( s_to_i(vs[i]) );
	}
	return vi;
}

vector<string> split(string s){
	vector<string> vc;
	string s_;
	
	for(int i=0 ; i<(int)s.size() ; i++ ){
		char c = s[i];
		
		if( s[i] == ',' ){
			vc.push_back( s_ );
			s_.clear();
		}else{
			s_.push_back( c );
			if( i == (int)s.size()-1 ){
				vc.push_back( s_ );
			}
		}
	}
	return vc;
}

int main(){
	string s;
	vector<int> a[101];
	int b[101][101] = {0};
	int i;
	
	for(i=0 ; getline(cin,s) ; i++ ){
		vector<string> vc = split( s );
		a[i] = vs_to_vi( vc );
		//i++;
		//if( i==9 ) break;
	}
	b[0][0] = a[0][0];
	for(int j=1 ; j<i ; j++ ){
		if( j <= i/2 ){
			for(int k=0 ; k <= j ; k++ ){
				if( k == 0 ){
					b[j][k] = a[j][0] + b[j-1][k];
				}else{
					b[j][k] = a[j][k] + max( b[j-1][k] , b[j-1][k-1] );
				}
			}
		}else{
			for(int k=0 ; k < i-j ; k++ ){
				b[j][k] = a[j][k] + max( b[j-1][k] , b[j-1][k+1] );
			}
		}
	}
	cout << b[i-1][0] << endl;
}