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

int a[100][100];
int dp[100][100];
int n;

int main()
{
    string s;
    while(getline(cin, s)){
        int k = 0;
        stringstream ss(s);
        while(ss >> a[n][k]){
            ss.ignore();
            k++;
        }
        n++;
    }
    
    dp[0][0] = a[0][0];
    
    for(int i = 1; i < n / 2 + 1; ++i){
        for(int j = 0; j <= i; ++j){
            if(j == 0) dp[i][j] = a[i][j] + dp[i-1][j];
            else if(j == i) dp[i][j] = a[i][j] + dp[i-1][j-1];
            else dp[i][j] = a[i][j] + max(dp[i-1][j], dp[i-1][j-1]);
        }
    }
    
    for(int i = n / 2 + 1; i < n; ++i){
        for(int j = 0; j < n - i; ++j){
            dp[i][j] = a[i][j] + max(dp[i-1][j], dp[i-1][j+1]);
        }
    }
    
    cout << dp[n-1][0] << endl;
}