#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 300

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

int dp[ARRAY_MAX][ARRAY_MAX];

int main() {

	string s;
	vector<vector<int> > vec;

	while (getline(cin, s))
	{
		vector<int> a;
		int siz = s.size();
		int t = 0;
		for (int i = 0; i < siz; i++)
		{
			if (isdigit(s[i]))
			{
				t = t * 10 + s[i] - '0';
			}
			if (s[i] == ',' || i == siz - 1)
			{
				a.push_back(t);
				t = 0;
			}
		}
		vec.push_back(a);
	}


	dp[0][0] = vec[0][0];
	int center = vec.size() / 2;


	for (int i = 0; i < vec.size() - 1; i++)
	{
		for (int j = 0; j < vec[i].size(); j++)
		{
			if (i < center)
			{
				//配るdp
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + vec[i + 1][j + 1]);
			}
			else
			{
				if (j == 0)
				{

					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
				}
				else if (j == vec[i].size() - 1)
				{
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + vec[i + 1][j - 1]);
				}
				else
				{
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + vec[i + 1][j - 1]);
				}
			}
		}
	}
	cout << dp[vec.size() - 1][0] << endl;

	return 0;
}
