#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
const int N = 101;
int dp[N][N];
vector<int> split(string s)
{
	vector<int> res;
	for (int i=0; i<s.size(); ++i) if (s[i] == ',') s[i] = ' ';
	istringstream is(s);
	int t;
	while (is >> t) res.push_back(t);
	return res;
}
int main()
{
	string in;
	int k = 0;
	int pn = 0;
	while (cin >> in) {
		vector<int> a = split(in);
		int n = a.size();
		if (k == 0) {
			dp[0][0] = a[0];
		}
		else {
			if (n >= pn) {
				dp[k][0] = dp[k-1][0] + a[0];
				for (int i=1; i<n; ++i)
					dp[k][i] = max(dp[k-1][i-1], dp[k-1][i]) + a[i];
			}
			else {
				for (int i=0; i<n-1; ++i)
					dp[k][i] = max(dp[k-1][i], dp[k-1][i+1]) + a[i];
				dp[k][n-1] = dp[k-1][n-1] + a[n-1];
			}
		}
		pn =n;
		k++;
	}
	cout << dp[k-1][0] << endl;
	return 0;
}