#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	char c[202];
	char *cp;
	int n[102][102],i,j,k,m=0,p,an=0;
    memset(n,0,sizeof(n));
	while(gets(c)!=NULL) {
     cp=c; k=1; p=0;
	 while(p<strlen(c)) {
      n[m+1][k++]=atoi(cp);
	  while(c[p]!=',' && p<strlen(c)) p++;
	  p++; cp=&c[p];
	 }
     m++;
	}
	for (i=1;i<=m/2+1;i++) for (j=1;j<=i;j++) {
		n[i][j]+=max(n[i-1][j],n[i-1][j-1]);
		n[m-i+1][j]+=max(n[m-i+2][j],n[m-i+2][j-1]);
        if (i==m/2+1) an=max(an,n[i][j]);
	}
	cout << an << endl;
	return 0;
}