#include <bits/stdc++.h>
using namespace std;

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define EB				emplace_back

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

vector<int> G[120];
int dp[100][100];

signed main() {
	fill( dp[0], dp[100], 0 );

	int cnt = 0;
	string s;
	while( getline( cin, s ) ) {
		for( int i = 0; i < s.size(); i += 2 ) {
			if( s[i + 1] == ',' || i == s.size() - 1 ) {
				G[cnt].EB( s[i] - '0' );
			} else {
				G[cnt].EB( ( s[i] - '0' ) * 10 + s[i + 1] - '0' );
				i++;
			}
		}
		cnt++;
	}

	dp[0][0] = G[0][0];
	REP( i, cnt ) {
		REP( j, G[i + 1].size() ) {
			int add = G[i + 1][j];
			
			if( i + 1 <= cnt / 2 ) {
				if( j == 0 ) {
					dp[i + 1][j] = dp[i][j] + add;
				} else if( j == G[i + 1].size() - 1 ) {
					dp[i + 1][j] = dp[i][G[i].size() - 1] + add;
				} else {
					dp[i + 1][j] = max( dp[i][j - 1], dp[i][j] ) + add;
				}
			} else {
				dp[i + 1][j] = max( dp[i][j], dp[i][j + 1] ) + add;
			}
			
		}
	}

	cout << dp[cnt - 1][0] << endl;
	

}
