#include<bits/stdc++.h>
using namespace std;

int data[111][111];
int cnt;
int memo[111][111];

int solve(int x, int y){

  if(data[y][x] == -1<<28 || x < 0) return -1<<28;
  if(y == cnt-1) return data[y][x];
  if(~memo[y][x]) return memo[y][x];
  
  int ret = -1<<28;
  ret = max(ret, solve(x, y+1));
  if(cnt/2 < y) ret = max(ret, solve(x-1, y+1));
  else ret = max(ret, solve(x+1, y+1));

  return memo[y][x] = ret += data[y][x];
}

int main(){

  for(int i=0;i<111;i++)
    for(int j=0;j<111;j++) data[i][j] = -1<<28;
  
  string s;
  while(getline(cin, s)){
    int n = 0, w = 0;
    for(int i=0;i<s.size();i++){
      if(s[i] == ','){
	data[cnt][w++] = n;
	n = 0;
	continue;
      }
      n *= 10;
      n += s[i] - '0';
    }
    data[cnt++][w] = n;
  }

  memset(memo, -1, sizeof(memo));
  cout << solve(0, 0) << endl;
}