#include<iostream>
#include<sstream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    string InputString;
    int Num,Count=0;
    int Value[128][128];
    int CalcTable[128][128];

    while(getline(cin,InputString)){
        istringstream is(InputString);
        for(int i=0;is>>Num;++i){
            is.ignore();
            Value[Count][i]=Num;
        }
        Count++;
    }

    CalcTable[0][0]=Value[0][0];
    Count--;

    for(int i=1;i<=Count/2;++i){
        for(int j=0;j<=i;++j){
            if(!j)CalcTable[i][j]=Value[i][j]+CalcTable[i-1][j];
            else if(j==i)CalcTable[i][j]=Value[i][j]+CalcTable[i-1][j-1];
            else CalcTable[i][j]=Value[i][j]+max(CalcTable[i-1][j-1],CalcTable[i-1][j]);
        }
    }

    for(int i=Count/2+1;i<=Count;++i){
        for(int j=0;j<=Count-i;++j){
            CalcTable[i][j]=Value[i][j]+max(CalcTable[i-1][j],CalcTable[i-1][j+1]);
        }
    }

    cout<<CalcTable[Count][0]<<endl;

    return 0;
}