#include <iostream>
#include <vector>
#include <string>

using namespace std;

void solve()
{
	string str;
	int digits[102][102] = {0};
	int row = 0;
	while(getline(cin, str))
	{
		int column = 1;
		int digit = 0;
		string temp;
		for(int i = 0; i < str.size(); ++i)
		{
			if(str[i] == ',')
			{
				digits[row][column] = atoi(temp.c_str());
				++column;
				temp ="";
			}
			else
			{
				temp += str[i];
			}
		}
		digits[row][column] = atoi(temp.c_str());
		++row;
	}
	int memo[102][102] = {0};
	memo[0][1] = digits[0][1];
	int n = row / 2 + 1;
	for(int i = 1; i < n; ++i)
	{
		for(int j = 1; j < 102; ++j)
		{
			memo[i][j] = digits[i][j] + max(memo[i - 1][j - 1], memo[i - 1][j]);
		}
	}
	for(int i = n; i < row; ++i)
	{
		for(int j = 1; j < 101; ++j)
		{
			memo[i][j] = digits[i][j] + max(memo[i - 1][j], memo[i - 1][j + 1]);
		}
	}
	cout << memo[row - 1][1] << endl;
}

int main()
{
	solve();
	return(0);
}