#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int mtx[210][110];
int dp[210][110];

int main() {
	char s[1000];
	int x,y;
	for(y=0;gets(s);y++){
		int len=strlen(s);
		int i;
		x=0;
//cout<<s<<endl;
//cout<<len<<endl;
//cout<<s[0]-'0'<<endl;
		for(i=0;i<len;){
			if('0'<=s[i]&&s[i]<='9'){
				if(i+1<len&&'0'<=s[i+1]&&s[i+1]<='9'){
					mtx[y][x++]=(s[i]-'0')*10+s[i+1]-'0';
					i+=3;
				}else{
					mtx[y][x]=s[i]-'0';
//cout<<y<<" "<<x<<" "<<s[i]<<endl;
					x++;
					i+=2;
				}
			}
		}
	}
	
	int maxy=y;
	/*for(y=0;y<maxy;y++){
		for(x=0;x<min(y+1,maxy-y);x++){
			cout<<mtx[y][x]<<" ";
		}
		cout<<endl;
	}
	*/
	for(y=0;y<maxy;y++){
		if(y==0)dp[0][0]=mtx[0][0];
		else if(y<maxy/2+1){
			for(x=0;x<=y;x++){
				dp[y][x]=max(dp[y-1][x],x==0?0:dp[y-1][x-1])+mtx[y][x];
			}
		}else{
			for(x=0;x<maxy-y;x++){
				dp[y][x]=max(dp[y-1][x],x==maxy-y-1?0:dp[y-1][x+1])+mtx[y][x];
			}
		}
	}
	cout<<dp[maxy-1][0]<<endl;
/*for(y=0;y<maxy;y++){
	for(x=0;x<min(y+1,maxy-y);x++){
		cout<<dp[y][x]<<" ";
	}
	cout<<endl;
}*/

	return 0;
}