#include<iostream>

int a[100][50];
int dp[100][50];

int main()
{
	int n, l = 0;
	while( std::cin >> n )
	{
		static int j;

		a[l][j++] = n;
		char c = std::cin.get();

		if( c == '\n' )
		{
			++l;
			j = 0;
		}
	}

	dp[0][0] = a[0][0];

	for( int i = 0; i != l; ++i )
	{
		for( int j = 0; j <= std::min( i, l - 1 - i ); ++j )
		{
			if( i <= l / 2 )
			{
				if( j )
					dp[i][j] = dp[i-1][j-1] + a[i][j];

				if( j <= std::min( i - 1, l - 1 - i + 1 ) + 1 )
					dp[i][j] = std::max( dp[i][j], dp[i-1][j] + a[i][j] );
			}
			else
				dp[i][j] = std::max( dp[i-1][j], dp[i-1][j+1] ) + a[i][j];
		}
	}

	std::cout << dp[l-1][0] << std::endl;

	return 0;
}