#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

vector<string> split(const string &str, char sep)
{
  vector<string> v;
  auto first = str.begin();
  while( first != str.end() ) {
    auto last = first;
    while( last != str.end() && *last != sep ) ++last;
    v.push_back(std::string(first, last));
    if( last != str.end() ) ++last;
    first = last;
  }
  return v;
}

signed main(void)
{
  string s;

  int ii = 0, d[105][105];
  REP(i, 105) REP(j, 105) d[i][j] = -1;
  while(cin >> s) {
    vector<string> v = split(s, ',');
    REP(i, v.size()) {
      d[ii][i] = stoi(v[i]);
    }
    ii++;
  }
  int num = (ii+1)/2;
  /*REP(i, ii+1) {
    REP(j, num+1) {
      cout << d[i][j] << " ";
    }
    cout << endl;
  }*/

  int dp[105][105];
  REP(i, 105) REP(j, 105) dp[i][j] = -1;
  dp[0][0] = d[0][0];

  FOR(i, 1, num+1) {
    REP(j, i+1) {
      //cout << j << " ";
      if(j > 0) {
        dp[i][j] = max(dp[i][j], d[i][j] + max(dp[i-1][j-1], dp[i-1][j]));
      }
      else {
        dp[i][j] = max(dp[i][j], d[i][j] + dp[i-1][j]);
      }
      //cout << d[i][j] << " " << dp[i-1][j] << " ";
    }
  }
  FOR(i, num+1, ii+1) {
    REP(j, 2*num-i+1) {
      //cout << j << " ";
      dp[i][j] = max(dp[i][j], d[i][j] + max(dp[i-1][j], dp[i-1][j+1]));
    }
  }

  cout << dp[ii][0] << endl;

  return 0;
}