#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


vector<string> split(string& s,char c){
  int n=s.size();
  vector<string> res;
  for(int i=0;i<n;i++){
    if(s[i]==c) continue;
    string t;
    while(i<n&&s[i]!=c) t.push_back(s[i++]);
    res.push_back(t);
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  vector<string> ss;
  {
    string s;
    while(cin>>s) ss.emplace_back(s);
  }
  int n=ss.size();
  vector< vector<int> > vs(n);
  for(int i=0;i<n;i++)
    for(auto s:split(ss[i],','))
      vs[i].emplace_back(stoi(s));

  vector< vector<int> > dp(vs);
  for(int i=0;i+1<n;i++){
    for(int j=0;j<n;j++){
      for(int k=-1;k<=1;k++){
        if(j+k<0) continue;

        if(i<n/2 && k<0) continue;
        if(i>=n/2 && k>0) continue;

        if(j>=(int)dp[i].size()) continue;
        if(j+k>=(int)dp[i+1].size()) continue;

        chmax(dp[i+1][j+k],dp[i][j]+vs[i+1][j+k]);
      }
    }
  }

  cout<<dp[n-1][0]<<endl;
  return 0;
}

