#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	string s;vector <string> ma;int dp[120][120],num[120][120];
	while(cin>>s) ma.push_back(s);
	int n=ma.size();
	memset(num,-1,sizeof(num));
	rep(i,n) rep(j,ma.size()){if(ma[i][j]==',') ma[i][j]=' ';}
	rep(i,n){
		int t=abs(i-n/2);istringstream sin(ma[i]);
		rep(j,n/2+1-t) sin>>num[i][t+j*2]; 
	}
	memset(dp,-1,sizeof(dp));dp[0][n/2]=num[0][n/2];
	rep(i,n-1) rep(j,n){
		if(num[i+1][j-1]>=0) dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+num[i+1][j-1]);
		if(num[i+1][j+1]>=0) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+num[i+1][j+1]);
	}
	cout<<dp[n-1][n/2]<<endl;
}