#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


vector<vi> v;
vector<vi> d(110,vi(110,-1));


int calc(int y,int x){
	if(d[y][x]!=-1)return d[y][x];
	int ret=0;
	if(y==v.size()-1)ret=v[y][0];
	else if(y<v.size()/2){
		if(x+1<v[y+1].size())ret=v[y][x]+max(calc(y+1,x),calc(y+1,x+1));
		else ret=v[y][x]+calc(y+1,x);
	}
	else{
		if(x==0)ret=v[y][x]+calc(y+1,x);
		else if(x<v[y+1].size())ret=v[y][x]+max(calc(y+1,x),calc(y+1,x-1));
		else ret=v[y][x]+calc(y+1,x-1);
	}
	return d[y][x]=ret;
}



int main(){
	int n,e;
	char c;
	vi u;
	while(1){
		e=scanf("%d%c",&n,&c);
		if(e==EOF)break;
		u.pb(n);
		if(c=='\n'){
			v.pb(u);
			u.clear();
		}
	}
	// rep(i,v.size()){
	// 	rep(j,v[i].size()){
	// 		if(j!=0)cout<<",";
	// 		cout<<v[i][j];
	// 	}
	// 	cout<<endl;
	// }
	cout<<calc(0,0)<<endl;
}