#include<vector>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;


int main(){
  int st=0,index=0;
  string s;
  vector<int> vec[200];
  int dp[220][220];
  for(int i=0;i<220;i++)for(int j=0;j<220;j++)dp[j][i] = 0;
  while(cin >> s){
    for(int i=0;i<=s.length();i++){
      if(i == s.length() || s[i] == ','){
	vec[index].push_back((atoi)(s.substr(st,i-st).c_str()));
	st = i+1;
      }
    }
    st = 0;
    index++;
  }
  /*
  for(int i=0;i<index;i++){
    for(int j=0;j<vec[i].size();j++){
      cout << vec[i][j] << " ";
    }
    cout << endl;
  }


  for(int i=0;i<=vec[index%2==0?index/2-1:index/2].size();i++){
    cout<< dp[index%2==0?index/2-1:index/2][i] << " "; 
  }
  cout<< endl;
  */
  //cout << "pre index = " << index << endl;
  int A,B;
  A = B = 0;
  A = dp[0][0] = vec[0][0];
  //index%2==0?cout<< "index = " << index/2-1:cout << "index = " << index/2;
  //cout << endl;
  for(int i=1;i<=(index%2==0?index/2-1:index/2);i++){
    //cout << "i = " << i << endl;
    for(int j=0;j<(int)vec[i].size();j++){   
      dp[i][j] = vec[i][j]+max(dp[i][j],max(dp[i-1][j],j-1>=0?dp[i-1][j-1]:0));
      //cout << "dp["<<i<<"]["<<j<<"] = " << dp[i][j] << endl;
      if(i == (index%2==0?index/2-1:index/2))A = max(A,dp[i][j]);
    }
  }
  
  dp[index-1][0] = vec[index-1][0];
  index >= 2 ? B=dp[index-1][0]:0; 
  for(int i=index-2;i>(index%2==0?index/2-1:index/2);i--){
    cout<< "i = " << i << endl;
    for(int j=0;j<(int)vec[i].size();j++){
      dp[i][j] = vec[i][j] + max(dp[i][j],max(dp[i+1][j],j-1>=0?dp[i+1][j-1]:0));
      if(i == (index%2==0?index/2-1:index/2)+1)B = max(B,dp[i][j]);
      //cout<< "dp["<<i<<"]["<<j<<"] = " << dp[i][j] << endl;
    }
  }
  cout << A+B << endl;
  return 0;
}