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

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

int input[100][100];
int sum[100][100];
int lc[100];
char inbuf[500];

int main() {
  int i,j,k,cc = 0,cy;
  memset(input, 0, sizeof(input));
  memset(sum, 0, sizeof(sum));
  while(~scanf("%s", inbuf)) {
    cy = 0;
    char *tmp = strtok(inbuf, ",");
    input[cc][cy] = atoi(tmp);
    cy++;
    while((tmp = strtok(NULL, ",")) != NULL) {
      input[cc][cy] = atoi(tmp);
      cy++;
    }
    lc[cc] = cy;
    cc++;
  }

  sum[0][0] = input[0][0];
  rep(i,cc) {
    rep(j, lc[i]) {
      sum[i+1][j] = max(sum[i+1][j], sum[i][j]+input[i+1][j]);
      if(i < cc/2) {
	sum[i+1][j+1] = max(sum[i+1][j+1], sum[i][j]+input[i+1][j+1]);
      }else{
	sum[i+1][j-1] = max(sum[i+1][j-1], sum[i][j]+input[i+1][j-1]);
      }
    }
  }

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