#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector <int> VI;
typedef vector <VI> VVI;

#define MAX 120

int main( void )
{
	VVI G( MAX, VI( MAX, 0 ) );

	// üÍ
	int cnt = 0;
	while ( cin.eof() == false )
	{
		string input;
		getline( cin, input );

		replace( input.begin(), input.end(), ',', ' ' );
		istringstream is( input );

		int n;
		int m = 0;
		while ( is >> n )
		{
			G[cnt][m] = n;
			m++;
		}

		cnt++;
		if ( cin.eof() ) break;
	}

	int middle = cnt/2;
	for ( int i = 1; i <= middle; i++ )
	{
		for ( int j = 0; j < i; j++ )
		{
			for ( int k = middle; k > 0; k-- )
			{
				swap( G[middle+i][k], G[middle+i][k-1] );
			}
		}
	}

	VVI dp = VVI( MAX, VI( MAX, 0 ) );
	dp[0][0] = G[0][0];
	for ( int i = 0; i < MAX; i++ )
	{
		for ( int j = 0; j < MAX; j++ )
		{
			if ( dp[i][j] != 0 )
			{
				if ( G[i+1][j] > 0 )
					dp[i+1][j] = max( dp[i+1][j], G[i+1][j] + dp[i][j] );
				if ( G[i+1][j+1] > 0 )
					dp[i+1][j+1] = max( dp[i+1][j+1], G[i+1][j+1] + dp[i][j] );
			}
		}
	}

	int answer = 0;
	for ( int i = 0; i < MAX; i++ )
	{
		answer = max( answer, dp[cnt-1][middle] );
	}
	cout << answer << endl;
	return 0;
}