#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
  
int main(void){
  string in;
  const char* delim = ",";
  int rowsize = 0;
  int colsize = 0;
  vector<vector<int> > d;
  while(getline(cin,in)){
    char s[1000];
    vector<int> tmp;
    strcpy(s,in.c_str());
    for(const char *token=strtok(s,delim);token;token=strtok(0,delim)){
      int t = atoi(token);
      tmp.push_back(t); 
    }
    d.push_back(tmp);
    rowsize = max(rowsize,(int)tmp.size());
    colsize++;
  }
  vector<int> dp(rowsize+1);
  vector<int> dp2(rowsize+1);
  REP(i,(colsize+1)/2){
    vector<int> ndp = dp;
    vector<int> ndp2 = dp2;
    REP(j,i+1){
      ndp[j+1] = d[i][j] + max(dp[j],dp[j+1]);
      ndp2[j+1] = d[colsize-1-i][j] + max(dp2[j],dp2[j+1]);
    }
    dp = ndp;
    dp2 = ndp2;
  }
  int ans = 0;
  REP(i,rowsize){
    ans = max(ans, dp[i+1]+dp2[i+1]-d[colsize/2][i]);
  }
  cout<<ans<<endl;
  
  return 0;
}