#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	int field[100][55],dp[100][55] = {};
	int cnt = 0,num = 0,tmp = 0;
	char c;
	for(int i = 0;i < 100;i++) for(int j = 0;j < 55;j++) field[i][j] = -1;
	while(c = getchar()){
		if(c == EOF) break;
		if(c == '\n') {
			field[cnt++][num] = tmp;
			tmp = 0;
			num = 0;
		}
		else if(c == ','){
			field[cnt][num++] = tmp;
			tmp = 0;
		}else{
			tmp = tmp * 10 + (c - '0');
		}
	}
	dp[0][0] = field[0][0];
	for(int i = 1;i < 100;i++){
		for(int j = 0;j < 50;j++){
			if(field[i][j] == -1) continue;
			if(i < cnt / 2){
				if(j >= 1) dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - 1]) + field[i][j];
				else dp[i][j] = dp[i - 1][j] + field[i][j];
			}else{
				dp[i][j] = max(dp[i - 1][j],dp[i - 1][j + 1]) + field[i][j];
			}
		}
	}
	cout << dp[cnt - 1][0] << endl;
	return 0;
}