#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int in[105][105];
int t[105][105];
int dp[105][105];

int stoi (string s )
{
	stringstream ss (s );
	int res = 0;
	ss >> res;

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.SPRP", "r", stdin );
	memset (in, -1, sizeof (in ) );
	memset (t, 0, sizeof (t ) );
	memset (dp, 0, sizeof (dp ) );
	string str = "";
	int row = 0, col = 0;
	while (getline (cin, str ) ){
		rep (i, str.length() ){
			if (str[i] == ',' ) str[i] = ' ';
		} // end rep
		col = 0;
		stringstream ss (str );
		string s = "";
		while (ss >> s ){
			in[row][col++] = stoi (s );
		} // end while
 		row++;
	} // end while
/*
	rep (i, row ){
		rep (j, row ){
			cout << setw(2) << in[i][j];
		} // end rep
		cout << endl;
	} // end rep
*/
	int n = (row+1)/2;
	int m = n-1;
	
	rep (i, n ){
		rep (j, n ){
//			cout << "i: " << i << " j: " << j << " i+j: " << i+j << " min(j,m): " << min(j,m ) << endl;
			t[i][j] = in[i+j][min(j, m )];
		} // end rep
		m--;
	} // end rep
/*
	rep (i, n ){
		rep (j, n ){
			cout << setw(2) << t[i][j];
		} // end rep
		cout << endl;
	} // end rep
*/
	dp[0][0] = t[0][0];
	for (int i = 1; i < n; i++ ) dp[i][0] = t[i][0] + dp[i-1][0];
	for (int j = 1; j < n; j++ ) dp[0][j] = t[0][j] + dp[0][j-1];
	for (int i = 1; i < n; i++ ){
		for (int j = 1; j < n; j++ ){
			dp[i][j] = t[i][j] + max (dp[i-1][j], dp[i][j-1] );
		} // end for
	} // end for

	printf ("%d\n", dp[n-1][n-1] );
		
	return 0;
}