#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll cnt[1000];
ll d[1000][1000];
ll dp[1000][1000];
ll dx[][2]{ {0,1},{0,-1} };

int main() {
	string s;
	ll i;
	for (i = 0; getline(cin, s) && s != ""; i++) {
		s += ',';
		stringstream ss(s);
		char c;
		for (; ss >> d[i][cnt[i]] >> c; cnt[i]++);
	}
	dp[0][0] = d[0][0];
	rep(j, i - 1) {
		rep(k, cnt[j]) {
			rep(t, 2) {
				ll nx = k + dx[j > i / 2][t];
				if (0 <= nx&&nx < cnt[j + 1])
					dp[j + 1][nx] = max(dp[j + 1][nx], dp[j][k] + d[j + 1][nx]);
			}
		}
	}
	printf("%d\n", dp[i - 1][0]);
}