#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	vvi a;
	for(string s;getline(cin,s);){
		replace(allof(s),',',' ');
		istringstream iss(s);
		a.push_back(vi());
		for(string s2;iss>>s2;)
			a.back().push_back(atoi(s2.c_str()));
	}
	
	vvi dp(a.size());
	rep(i,dp.size())
		dp[i].resize(a[i].size());
	
	dp[0][0]=a[0][0];
	repi(i,1,a.size()/2+1){
		dp[i][0]=dp[i-1][0]+a[i][0];
		dp[i][i]=dp[i-1][i-1]+a[i][i];
		repi(j,1,i)
			dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+a[i][j];
	}
	repi(i,a.size()/2+1,a.size()){
		rep(j,a.size()-i)
			dp[i][j]=max(dp[i-1][j],dp[i-1][j+1])+a[i][j];
	}
	
	cout<<dp.back()[0]<<endl;
	
	return 0;
}