#include <bits/stdc++.h>  

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

string s;
vector<vector<int> > field;
int dp[101][101] = {0};

int main() {
	while(getline(cin, s)){
		replace(s.begin(), s.end(), ',', ' ');
		int n;
		stringstream ss;
		ss << s;
		vector<int> v;
		while(ss >> n) v.push_back(n);
		field.push_back(v);
	}
	dp[0][0] = field[0][0];
	FOR(i, 1, field.size()) rep(j, field[i].size()) {
		if(i <= field.size() / 2) {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1]) + field[i][j];
		}
		else {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + 1]) + field[i][j];
		}
	}
	printf("%d\n", dp[field.size() - 1][0]);
	return 0;
}