#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int dp[110][110];
int a, c;

signed main(){
	vi tmp;
	vvi d;
	while (1) {
		int b = scanf("%d%c", &a, &c);
		if (b == EOF) break;
		tmp.pb(a);
		if (c == '\n') {
			d.pb(tmp);
			tmp.clear();
		}
	}
	int n = d.size() / 2 + 1;
	rep(i, 0, 2 * n - 1) {
		rep(j, 0, n) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = d[0][0];
	rep(i, 0, n - 1) {
		rep(j, 0, i + 1) {
			dp[i + 1][j] = max(dp[i + 1][j], d[i + 1][j] + dp[i][j]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], d[i + 1][j + 1] + dp[i][j]);
		}
	}
	rep(i, n, 2 * n - 1) {
		rep(j, 0, 2 * n - 1 - j) {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j + 1]) + d[i][j];
		}
	}
	/*rep(i, 0, 2 * n - 1) {
		rep(j, 0, n) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << dp[2 * n - 2][0] << endl;
}