#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int T[128][128], ex[128];
	vector<string> S;
	string s;

	while(cin >> s)
	{
		S.push_back(s);
	}
	
	for(int i = 0; i < S.size(); i++)
	{
		int n = i;
		if(i > S.size()/2)
		{
			n = S.size() - n-1;
		}
 		ex[i] = n;
	}

	for(int i = 0; i < S.size(); i++)
	{
		int m;
		stringstream ss;
		while(S[i].find(",") != string::npos)
		{
			m = S[i].find(",");
			S[i].replace(m, 1, " ");
		}
		ss.str(S[i]);
		
		int n = ex[i];
		for(int j = 0; j <= n; j++)
		{
			ss >> T[i][j];
		}
	}


	int dp[128][128] = {{ 0 }};
	dp[0][0] = T[0][0];
	for(int i = 0; i < S.size()/2; i++)
	{
		for(int j = 0; j <= i; j++)
		{
			for(int k = 0; k <= 1; k++)
			{
				dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + T[i+1][j+k]);
			}
		}
	}

	for(int i = S.size()/2; i < S.size()-1; i++)
	{
		int n = ex[i];
		for(int j = 0; j <= i + 1; j++)
		{
			for(int k = 0; k <= 1; k++)
			{
				if(j-k >= 0 && j+k <= i + 1)
				{
					dp[i+1][j-k] = max(dp[i+1][j-k], dp[i][j] + T[i+1][j-k]);
				}
			}
		}
	}
	/*
	for(int i = 0; i < S.size(); i++)
	{
		for(int j = 0; j <= i; j++)
		{
			printf("%d ",dp[i][j]);
		}
		puts("");
	}
	*/
	cout << dp[S.size()-1][0] << endl;
}