#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int i = 0, j = 0;
//	char c;
	int a[100][50];
	int b[100][50];
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	
	while (cin >> a[i][j]) {
		while (cin.get() != '\n') {
			j++;
			cin >> a[i][j];
		}
		i++;
		j = 0;
	}

	b[0][0] = a[0][0];

	for (int k = 1; k <= i / 2; k++) {
		b[k][0] = b[k - 1][0] + a[k][0];
		b[k][k] = b[k - 1][k - 1] + a[k][k];
		for (int s = 1; s < k; s++)
			b[k][s] = max(b[k - 1][s - 1], b[k - 1][s]) + a[k][s];
	}

	for(int k = i / 2 + 1; k <= i; k++)
		for (int s = 0; s < i - k + 1; s++)
			b[k][s] = max(b[k - 1][s], b[k - 1][s + 1]) + a[k][s];

			cout << b[i][0] << endl;
		
	return 0;
}

