#include <bits/stdc++.h>
#define range(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) range(i,0,n)
using namespace std;

int a[110][110];
int dp[110][110];

int main(void){
	int n=0;
	while(1){
		string s;
		cin >> s;
		if(cin.eof()) break;
		stringstream ss(s);
		int index=0;
		ss >> a[n][index++];
		char tmp;
		while(!ss.eof()) ss >> tmp >> a[n][index++];
		n++;
	}

	rep(i,n/2){
		rep(j,105){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]+a[i][j]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+a[i][j]);
		}
	}
	const int m=n/2;
	rep(i,n/2){
		rep(j,105){
			dp[m+i+1][j]=max(dp[m+i+1][j],dp[m+i][j]+a[m+i][j]);
			dp[m+i+1][j]=max(dp[m+i+1][j],dp[m+i][j+1]+a[m+i][j+1]);
		}
	}

	cout << dp[n-1][0]+a[n-1][0] << endl;
	return 0;
}