#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
	int a[100][50];
	string s;
	int c = 0;
	while(getline(cin,s)){
		istringstream is(s);
		is >> a[c][0];
		char b;
		int n = 1;
		while(is >> b >> a[c][n++]){}
		c++;
	}
	int d = (c+1)/2;
	int dp[c][d];
	dp[0][0] = a[0][0];
	for(int i=1;i<d;i++){
		for(int j=0;j<=i;j++){
			if(j==0) dp[i][j] = a[i][j] + dp[i-1][j];
			else if(j==i) dp[i][j] = a[i][j] + dp[i-1][j-1];
			else dp[i][j] = a[i][j] + max(dp[i-1][j],dp[i-1][j-1]);
		}
	}
	for(int i=d;i<c;i++){
		for(int j=0;j<c-i;j++){
			dp[i][j] = a[i][j] + max(dp[i-1][j],dp[i-1][j+1]);
		}
	}
	cout << dp[c-1][0] << endl;
}