#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	int data[100][100] = {0};
	int count1 = 0;
	int count2 = 0;
	while(getline(cin, str))
	{
		str += ',';
		int n = str.size();
		string temp;
		int size = 0;
		for(int i = 0; i < n; ++i)
		{
			if(str[i] == ',')
			{
				char* c = new char[size];
				for(int j = 0; j < size; ++j)
				{
					c[j] = temp[j];
				}
				data[count1][count2] = atoi(c);
				delete c;
				++count2;
				size = 0;
				temp.clear();
			}
			else
			{
				temp += str[i];
				++size;
			}
		}
		++count1;
		count2 = 0;
		str.clear();
	}
	int Ans[100][100] = {0};
	Ans[0][0] = data[0][0];
	for(int i = 1; i < (count1 + 1) / 2; ++i)
	{
		for(int j = 0; j < i; ++j)
		{
			Ans[i][j]     = max(data[i][j] + Ans[i - 1][j], Ans[i][j]);
			Ans[i][j + 1] = max(data[i][j + 1] + Ans[i - 1][j], Ans[i][j + 1]);
		}
	}
	for(int i = (count1 + 1) / 2; i < count1; ++i)
	{
		for(int j = 0; j < count1 - i; ++j)
		{
			Ans[i][j] = max(data[i][j] + Ans[i - 1][j], data[i][j] + Ans[i - 1][j + 1]);
		}
	}
	cout << Ans[count1 - 1][0] << endl;
}

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