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

int main(){
  string s;
  int m=0;
  vector<int> v[101];
  int dp[101][101];
  memset(dp,0,sizeof(dp));
  while(getline(cin,s)){
    stringstream ss(s);
    int n;
    char c;
    while(ss>>n){
      v[m].push_back(n);
      ss>>c;
    }
    ++m;
  }
  dp[0][0]=v[0][0];
  for(int i=1;i<m;++i){
    for(int j=0;j<v[i].size();++j){
      dp[i][j]=dp[i-1][j]+v[i][j];
      if(i<=m/2&&j!=0) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+v[i][j]);
      else if(i>m/2&&j<v[i].size()-1) dp[i][j]=max(dp[i][j],dp[i-1][j+1]+v[i][j]);
    }
  }
  cout<<dp[m-1][0]<<endl;
  return 0;
}