#include<iostream>

#define MAX 101

using namespace std;

class CNum{
public:
	CNum():num(0),cost(0){}
	int num;
	int cost;
};

int main(void){
	int l = 1;
	int num = 0;
	CNum M[MAX][MAX];

	cin >> M[l++][1 + num].num;
	cin.ignore(MAX,'\n');
	do{
		num = 0;
		while( true ){
			char c;
			cin >> M[l][1 + num++].num;
			c = cin.get();
			if( c != ',' ) break;
		}
		cin.ignore(MAX,'\n');
		l++;
	}while(num > 1);

	for(int i = 1; i < l; i++){
		for(int j = 1; j < l / 2 + 1; j++){
			int d = M[i][j].num;
			/*cout << d << " ";
			cout << M[i-1][i>l/2?j:j-1].cost + d <<"," << M[i-1][i>l/2?j+1:j].cost + d<<" ";*/
			M[i][j].cost = max(M[i-1][i>l/2?j:j-1].cost + d, M[i-1][i>l/2?j+1:j].cost + d);
		}
	}
	cout << M[l-1][1].cost << endl;
	return 0;
}