#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a[100][100],b[100][100],i,j,n;
	for(i=0;i<100;++i)
		for(j=0;j<100;++j)
			a[i][j]=b[i][j]-1;
	for(i=0;;++i)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=i;++j)
		{
			if(scanf(",%d",&a[i][j])<1)
			{
				n = i-1;
				goto NEXT;
			}
		}
	}
NEXT:
	for(i=n+2;i<=2*n;++i)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=2*n-i;++j)
			scanf(",%d",&a[i][j]);
	}
	//a[2*n][n+1]ツづ慊づアツクツセツスツ催妥・ツアツクツセツス

	b[0][0]=a[0][0];
	for(i=1;i<=n;++i)
	{
		for(j=0;j<=i;++j)
		{
			if(j==0) b[i][0] = a[i][0]+b[i-1][0];
			else if(j==i) b[i][i] = a[i][i]+b[i-1][i-1];
			else b[i][j] = a[i][j] + max(b[i-1][j], b[i-1][j-1]);
		}
	}
	for(i=n+1;i<=2*n;++i)
	{
		for(j=0;j<=(2*n-i);++j)
		{
			b[i][j] = a[i][j] + max(b[i-1][j],b[i-1][j+1]);
		}
	}
	printf("%d\n",b[2*n][0]);
	return 0;
}