#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int b[110][110];
int dp[110][110];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for (int i = 0; i < 110; i++) {
		for (int j = 0; j < 110; j++) {
			b[i][j] = -1;
		}
	}

	int n = 0;
	string s;
	while (cin >> s) {
		int m = s.size() / 2 + 1;
		for (int i = 0; i < m; i++) {
			b[n][i] = s[i * 2] - '0';
		}
		n++;
	}

	dp[0][0] = b[0][0];
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < n; j++) {
			if (b[i][j] == -1) continue;
			for (int d = -1; d <= 1; d++) {
				if (i < n / 2 && d == -1 || n / 2 <= i && d == 1) continue;
				if (0 <= j + d && j + d < n && b[i + 1][j + d] != -1) {
					dp[i + 1][j + d] = max(dp[i + 1][j + d], dp[i][j] + b[i + 1][j + d]);
				}
			}
		}
	}

	cout << dp[n - 1][0] << endl;;
}