#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  vector<string> data;
  char __s[252];
  while(~scanf("%s",__s)){
    string tmp(__s);
    if(tmp=="HELLO")break;
    data.push_back(string(__s));
  }
  int n = data.size();
  int val[n][n];
  int dp[n][n];
  REP(i,n)REP(j,n)val[i][j]=dp[i][j]=0;
  REP(i,n){
    string s = data[i];
    s += ",";
    int tmp = 0;
    int iter = max<int>(0,n/2-i);
    REP(j,s.size()){
      if(s[j]==','){
        val[i][iter++] = tmp;
        tmp = 0;
      }else{
        tmp *= 10;
        tmp += (s[j]-'0');
      }
    }
  }
  REP(i,n)REP(j,n){
    if(i==0){
      dp[i][j] = val[i][j];
    }else{
      dp[i][j] = val[i][j] + max<int>(dp[i-1][j],dp[i-1][j+1]);
    }
  }
  cout<<dp[n-1][0]<<endl;
  return 0;
}