#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

static const int margin = 1;

int main() {
	char input[128][512];
	int vertex[128][64];
	int line;

	for(line = 0; fgets(input[line], 512, stdin) != NULL; line++);
	memset(vertex, 0, sizeof(vertex));

	for(int i = 0; i < line; i++) {
		for(int j = 0, k = 0; input[i][j] != '\n' && input[i][j] != '\0'; j++, k++) {
			int tmp = 0;

			for(;input[i][j] != ',' && input[i][j] != '\n' && input[i][j]; j++) {
				tmp *= 10;
				tmp += input[i][j] - '0';
			}

			if(i <= line / 2)
				vertex[margin + i][margin + k] = max(vertex[margin + (i - 1)][margin + (k - 1)], vertex[margin + (i - 1)][margin + k]) + tmp;
			else
				vertex[margin + i][margin + k] = max(vertex[margin + (i - 1)][margin + k], vertex[margin + (i - 1)][margin + (k + 1)]) + tmp;
		}
	}

	cout << vertex[margin + line - 1][margin] << endl;

	return 0;
}