/* ???????????¨?????????????????? */

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int m;
int as[1000][1000];
int dp[1000][1000];
char buf[10000];

int main() {
  while (1) {
    if (scanf("%s", buf) != 1) break;

    int cnt = 0;
    char *p = buf;
    int l = strlen(buf);
    while (p < buf+l) {
      char *next;
      long t = strtol(p, &next, 10);
      if (p == next) break;

      as[n][cnt] = t;
      p = next+1;
      ++cnt;
    }
    ++n;
    m = max(cnt, m);
  }

  dp[0][0] = as[0][0];
  for (int i=1; i<m; i++) {
    int lim = i+1;
    for (int j=0; j<lim; j++) {
      if (j-1 < lim-1) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + as[i][j]);
      if (j < lim-1) dp[i][j] = max(dp[i][j], dp[i-1][j] + as[i][j]);
    }
  }

  for (int i=m; i<n; i++) {
    int lim = m+m-(i+1);
    for (int j=0; j<lim; j++) {
      if (j < lim+1) dp[i][j] = max(dp[i][j], dp[i-1][j] + as[i][j]);
      if (j+1 < lim+1) dp[i][j] = max(dp[i][j], dp[i-1][j+1] + as[i][j]);
    }
  }

  printf("%d\n", dp[n-1][0]);
}