#include<iostream>
#include<vector>
#include <sstream>
#include <cstring>
using namespace std;
vector<vector<int> > list;
int dp[100][50];
int chack(int i,int j){
  //  cout<<i<<" "<<j<<endl;
  if(dp[i][j]!=-1)
    return dp[i][j];
  if(i==list.size()-1)
    return list[i][j];
  int max=list[i][j];
  int tmp1=-1,tmp2=-1;
  if(i<list.size()/2)
    {
      tmp1=chack(i+1,j);
      tmp2=chack(i+1,j+1);
      if(tmp1>tmp2)
	max+=tmp1;
      else
	max+=tmp2;
    }
  else
    {
      if(j<list[i+1].size())
	tmp1=chack(i+1,j);
      if(j>0)
	tmp2=chack(i+1,j-1);
      if(tmp1>tmp2)
	max+=tmp1;
      else
	max+=tmp2;
    }
  dp[i][j]=max;
  return max;
}

int main()
{
  memset(dp,-1,sizeof(dp));
  string str;

  while(getline(cin,str))
    {
      stringstream ss(str);
      int tmp;
      char a;
      vector<int> v;
      while(!ss.eof()){
	ss>>tmp>>a;
	v.push_back(tmp);
      }
      list.push_back(v);
    }
  cout<<chack(0,0)<<endl;
  /*
  for(int i=0;i<list.size();i++,cout<<endl)
    for(int j=0;j<list[i].size();j++)
      {
	cout<<list[i][j]<<" ";
      }
  for(int i=0;i<list.size();i++,cout<<endl)
    for(int j=0;j<list[i].size();j++)
      {
	cout<<dp[i][j]<<" ";
      }
  */
}