#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
#define P pair<int,int>
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(n) push_back(n)
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
struct edge{int cost,to;};

vector<string> split(string &in,char delimiter){
	vector<string> re; uint cur = 0,next;
	while((next = in.find_first_of(delimiter,cur)) != string::npos){
		re.pb(string(in,cur,next-cur));
		cur = next + 1;
	}
	re.pb(string(in,cur,in.size()-cur));
	return re;
}
vector<int> split_int(string &in, char delimiter){
	vector<string> str = split(in,delimiter);
	vector<int> re;
	rep(i,str.size()){
		re.pb(strtol(str[i].c_str(),NULL,10));
	}
	return re;
}


int main(){
	vector<int> in[110];
	int dp[110][110];
	memset(dp,0,sizeof(dp));
	string s;
	int cnt = 0;
	while(!((getline(cin,s),s.length()) == 1 && cnt != 0)){
		in[cnt] = split_int(s,',');
		cnt++;
	}
	in[cnt] = split_int(s,',');
	cnt++;
	dp[0][0] = in[0][0];
	for(int i = 1;i<105;i++)rep(j,in[i].size()){
		if(i <= cnt / 2){
			if(j-1<0){
				dp[i][j] = dp[i-1][j] + in[i][j];
				continue;
			}
			dp[i][j] = max(dp[i-1][j] + in[i][j],dp[i-1][j-1] + in[i][j]);
		}else{
			dp[i][j] = max(dp[i-1][j] + in[i][j],dp[i-1][j+1] + in[i][j]);
		}
	}
	int res = 0;
	rep(i,110){
		res = max(res,dp[i][0]);
	}
	cout << res << endl;
	return 0;
}