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

void split(string str, vector<string> &vc, char delim){

	string s;

	for(int i=0; i<str.length(); i++){
		if(str[i] != delim){
			s += str[i];
		}
		else {
			vc.push_back(s);
			s = "";
		}
	}
	vc.push_back(s);
	
}

int main(){

	int v[99][50], cnt;
	string str;
	vector<string> vc;
	
	cnt = 0;
	while(getline(cin, str)){
		vc.clear();
		split(str, vc, ',');
		for(int i=0; i<vc.size(); i++){
			v[cnt][i] = atoi(&vc[i][0]);
		}
		cnt++;
	}
	
	for(int i=1; i<cnt; i++){
		if(i < (cnt + 1) / 2){
			for(int j=0; j<=i; j++){
				if(j == 0) {
					v[i][j] += v[i-1][0];
				}
				else if(j == cnt){
					v[i][j] += v[i-1][j-1];
				}
				else {
					v[i][j] += max(v[i-1][j-1], v[i-1][j]);
				}
			}
		}
		else {
			for(int j=0; j<cnt-i; j++){
				v[i][j] += max(v[i-1][j], v[i-1][j+1]);
			}
		}
	}

	cout << v[cnt-1][0] << endl;

	return 0;

}