#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <sstream>
using namespace std;

int v[102][102];
int dp[102][102];

int main() {
    memset(v, 1, sizeof v);
    memset(dp, 0, sizeof dp);

    int height = 0;
    string s;
    for (int i=1; ; ++i) {
        if ( ! getline(cin, s)) break;
        stringstream ss(s);
        char c;
        for (int j=1; ; ++j) {
            if (1 < j && ! (ss >> c)) break;
            ss >> v[i][j];
        }
        ++ height;
    }

    for (int i=1; i<=height; ++i) {
        for (int j=1, l=min(i,height-i+1); j<=l; ++j) {
            if (i <= height-i+1) {
                dp[i][j] = v[i][j] + max(dp[i-1][j], dp[i-1][j-1]);
            } else {
                dp[i][j] = v[i][j] + max(dp[i-1][j], dp[i-1][j+1]);
            }
        }
    }
    cout << dp[height][1] << endl;
    return 0;
}