#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX = 50;

int sp2i(string str, int p)
{
	string::iterator s, g;
	s = str.begin();
	for (int i=0; i<p; i++)
	{
		s = find(s, str.end(), ',');
		s++;
	}
	g = find(s, str.end(), ',');
	string t = string(s, g);
	int c = 0;
	for (int i=0; i<t.size(); i++)
	{
		c *= 10;
		c += t[i] - '0';
	}

	return c;
}

int main()
{
	int d[MAX][MAX];
	memset(d, 0, sizeof(d));

	vector<string> dt;
	string s;
	while (cin >> s)
	{
		dt.push_back(s);
	}

	int S = dt.size();
	int N = S / 2;

	for (int i=0; i<=N; i++)
	{
		for (int j=0; j<=i; j++)
		{
			d[i-j][j] = sp2i(dt[i], j);
		}
	}

	for (int i=N; i>=1; i--)
	{
		for (int j=0; j<i; j++)
		{
			d[N-j][N-i+j+1] = sp2i(dt[S-i], j);
		}
	}

	int dp[MAX][MAX];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = d[0][0];
	for (int i=1; i<=N; i++)
	{
		dp[i][0] = dp[i-1][0] + d[i][0];
		dp[0][i] = dp[0][i-1] + d[0][i];
	}

	for (int i=1; i<=N; i++)
	for (int j=1; j<=N; j++)
	{
		dp[i][j] = d[i][j] + max(dp[i-1][j], dp[i][j-1]);
	}

	cout << dp[N][N] << endl;

	return 0;
}