#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"

vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {
	vector<string>sts;
	string st;
	vector<vector<int>>nums;
	while (cin >> st) {
		vector<string>sts = split(st, ',');
		vector<int>anums;
		for (auto s : sts) {
			anums.push_back(stoi(s));
		}
		nums.emplace_back(anums);
	}
	for (int i = 0; i < nums.size(); ++i) {
		if (i > nums.size()/2) {
			int plus = i - nums.size()/2;
			for (int j = 0; j < plus; ++j) {
				nums[i].insert(nums[i].begin(), 0);
			}
		}
		nums[i].resize(i + 1);
	}
	vector<vector<int>>dps(nums);
	for (int i = 0; i < dps.size(); ++i) {
		for (int j = 0; j < dps[i].size(); ++j) {
			dps[i][j] = 0;
		}
	}
	dps[0][0] = nums[0][0];
	for (int h = 0; h < dps.size()-1; ++h) {
		for (int w = 0; w <= h; ++w) {
			dps[h + 1][w] = max(nums[h + 1][w] + dps[h][w], dps[h + 1][w]);
			dps[h + 1][w + 1] = max(nums[h + 1][w + 1] + dps[h][w], dps[h + 1][w + 1]);
		}
	}
	cout << dps[dps.size() - 1][dps.size()/2] << endl;
	return 0;
}