#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


vector<int> parse(string s, char c)
{
	int pre = 0;
	vector<int> v;
	
	for (int i=0; i<s.length(); i++)
	{
		if (s[i] == c)
		{
			v.push_back(atoi(s.substr(pre, i - pre).c_str()));
			pre = i + 1;
		}
	}
	v.push_back(atoi(s.substr(pre, s.length() - pre).c_str()));
	
	return v;
}


int main()
{
	int m[100][100], mx, sz;
	string s;
	
	rep(i, 100) rep(j, 100) m[i][j] = -1;
	for (sz=0; getline(cin, s); sz++)
	{
		vector<int> v = parse(s, ',');
		REP(v.size()) m[sz][i] = v[i];
	}
	//mには左詰にひし形の情報が入る
	
	int dp[100][100];
	dp[0][0] = m[0][0];
	
	for (int i=1; i<=sz/2; i++)
	{
		for (int j=0; j<=i; j++)
		{
			if (j == 0)
			{
				dp[i][j] = m[i][j] + dp[i-1][0];
			} else if (j == i) {
				dp[i][j] = m[i][j] + dp[i-1][j-1];
			} else {
				dp[i][j] = m[i][j] + max(dp[i-1][j-1], dp[i-1][j]);
			}
		}
	}
	
	for (int i=sz/2+1; i<sz; i++)
	{
		for (int j=0; j<=sz-i; j++)
		{
			dp[i][j] = m[i][j] + max(dp[i-1][j], dp[i-1][j+1]);
		}
	}
	
	cout << dp[sz-1][0] << endl;
	
	return 0;
}