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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int ba[100][100];
  int h;
  for(h=0; cin>>ba[h][0]; h++)
    for(int i=1; scanf(",%d", &ba[h][i]); i++)
      ;
  int w = h/2+1;
  int dp[h][w];

  dp[0][0] = ba[0][0];
  for(int i=1; i<w; i++) {
    dp[i][0] = ba[i][0] + dp[i-1][0];
    for (int j=1; j<i; j++)
      dp[i][j] = ba[i][j] + max(dp[i-1][j-1], dp[i-1][j]);
    dp[i][i] = ba[i][i] + dp[i-1][i-1];
  }
  for(int i=w; i<h; i++)
    for (int j=0; j<h-i; j++)
      dp[i][j] = ba[i][j] + max(dp[i-1][j], dp[i-1][j+1]);

  cout << dp[h-1][0] << endl;
}