#include <iostream>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

int main(){
	int a[99][51];
	string s;
	int c = -1;
	while(cin >> s){
		char b;
		istringstream ss(s);
		c++;
		ss >> a[c][1];
		for(int i=0;i<s.size()/2;i++) ss >> b >> a[c][i+2];
	}
	int d = c/2+1;
	int p[99][51];
	for(int i=0;i<99;i++) for(int j=0;j<51;j++) p[i][j] = 0;
	p[0][1] = a[0][1];
	for(int i=1;i<=c;i++){
		int x = i+1;
		if(i>d){
			x = c-i+1;
			for(int j=1;j<=x;j++) p[i][j] = max(p[i-1][j],p[i-1][j+1]) + a[i][j];
		}
		else{
			for(int j=1;j<=x;j++) p[i][j] = max(p[i-1][j],p[i-1][j-1]) + a[i][j];
		}
	}
	cout << p[c][1] << endl;
}