#include<iostream>
#include<cstdio>
#include<algorithm>
#include<sstream>
using namespace std;
int a[150][100]={{0}};
int i=0;
int sum=0,ans=0;
int b[150][100]={{0}};
void check(int x,int y,int z);
int main(){
    string str;
    int j=0,num;
    while(getline(cin,str)){
        istringstream is(str);
        j=0;
        while(is>>num){
            is.ignore();
            a[i][j]=num;
            j++;
        }
        i++;
    }
    check(0,0,0);
    cout<<ans<<endl;

    return 0;
}
void check(int x,int y,int z){
    //cout<<x<<y<<z<<endl;
    if(b[x][y]>z){
            //cout<<"-"<<b[x][y]<<"-"<<z<<endl;
            return;
    }
    b[x][y]=z;
    if(y==i){
        ans=max(z+a[y][x],ans);
        return;
    }
    if(y==i-1)check(0,y+1,z+a[y][x]);
    else if(y<i/2){
        check(x,y+1,z+a[y][x]);
        check(x+1,y+1,z+a[y][x]);
    }
    else if(y>=i/2){
        check(x,y+1,z+a[y][x]);
        check(x-1,y+1,z+a[y][x]);
    }
    return;
}