#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	
	char str[128] = {0};
	int cnt = 1;
	int data[128][128] = {{0}};
	int q = 1;
	
	memset(data,-1,sizeof(data));
	
	while(scanf("%s",str) != EOF){
		
		for(int i = 0;i < strlen(str); i++){
			if(str[i] == ',')continue;
			else{
				data[cnt][q] = str[i] - 48;
				q++;
			}
		}
		q = 1;
		cnt++;
	}
	q = 2;
	int dp[128][128] = {{0}};
	int x = (cnt/2);
	
	memset(dp,-1,sizeof(dp));
	
	dp[1][1] = data[1][1];
	
	for(int i = 1;i <= cnt; i++){
		for(int j = 1;j <= q; j++){
			if(q <= x){
				if(j == 1){
					dp[i+1][j] = dp[i][j] + data[i+1][j];
				}
				else if(j == q){
					dp[i+1][j] = dp[i][j-1] + data[i+1][j];
				}
				
				else{
					dp[i+1][j] = max(dp[i][j-1]+data[i+1][j],dp[i][j]+data[i+1][j]);
				}
			}
			else{
				dp[i+1][j] = max(dp[i][j+1]+data[i+1][j],dp[i][j]+data[i+1][j]);
			}
		}
		(q <= x+1) ? q++ : q--;
	}
	
	printf("%d\n",dp[cnt-1][1]);	
	return 0;
}