#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int data[100][100];

int main()
{
	memset(data, 0, sizeof(data));
	char buf[512];
	int yy = 0;
	while (!cin.eof())
	{
		cin.getline(buf, sizeof(buf));
		if (strlen(buf) == 0)
			break;

		int xx = 1;
		for (char* p = strtok(buf, ","); p != NULL; p = strtok(NULL, ","), ++xx)
			data[yy][xx] = atoi(p);
		++yy;
	}

	for (int i = 1; i < yy; ++i)
	{
		int a = -1;
		int b = 0;
		if (i > (yy+1)/2)
		{
			a = 0;
			b = 1;
		}
		for (int j = 1; j <= (yy+1)/2; ++j)
			data[i][j] += max(data[i-1][j+a], data[i-1][j+b]);
	}

	printf("%d\n", data[yy-1][1]);

	return 0;
}