#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

int main(){
  string s;
  vector<vector<int> > field;
  while(getline(cin, s)){
    replace(s.begin(), s.end(), ',', ' ');
    int n;
    stringstream ss;
    ss << s;
    vector<int> v;
    while(ss >> n){
      v.push_back(n);
    }
    field.push_back(v);
  }
  
  int dp[101][101];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = field[0][0];
  for(int i = 1 ; i < field.size() ; i++){
    for(int j = 0 ; j < field[i].size() ; j++){
      if(i <= field.size() / 2){
	dp[i][j] = max(dp[i-1][j-1], 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[field.size()-1][0] << endl;
 
  /*
  for(int i = 0 ; i < field.size() ; i++){
    for(int j = 0 ; j < field[i].size() ; j++){  
      cout << field[i][j] << ' ';
    }
    cout << endl;
  }
  cout << endl;
      
  for(int i = 0 ; i < field.size() ; i++){
    for(int j = 0 ; j < field[i].size() ; j++){
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }
  */
  
  
}