#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
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 j = 0, m = s.size(), idx = 0;
        while (j < m) {
            string ss;
            while (j < m && s[j] != ',') ss += s[j++];
            j++;
            b[n][idx++] = atoi(ss.c_str());
        }
        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;;
}
