#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

void test(){freopen("test.txt", "r", stdin);}

int main(){
	string s;
	vector<vi> vv;
	while(getline(cin, s)){
		vector<int> v;
		stringstream ss;
		ss << s;
		int n;
		char c;
		while(ss >> n){
			ss >> c;
			v.push_back(n);
		}
		vv.push_back(v);
	}

	const int INF = 2<<29;

	reverse(all(vv));

	FOR(i, 1, vv.size()){
		rep(j, vv[i].size()){
			int left = j, right = j+1;
			if(i <= vv.size()/2){
				left--;
				right--;
			}
			if(left < 0) left = -INF;
			else left = vv[i-1][left];
			if(right >= vv[i-1].size()) right = -INF;
			else right = vv[i-1][right];

			vv[i][j] += max(left, right);
		}
	}

	cout << vv[vv.size()-1][0] << endl;

	return 0;
}