#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<string> line(100);
  int l,k;
  char cc;
  stringstream ss;
  for(l=0;getline(cin,line[l],'\n');l++);
  int path[(l+1)/2+2][l];
  for(int i=0;i<(l+1)/2+2;i++)path[i][0] = 0;
  for(int i=0;i<l;i++)path[0][i] = 0,path[(l+1)/2+1][i] = 0;
  ss<<line[0];
  ss>>path[1][0];
  for(int i=1;i<l;i++){
    ss.str("");
    ss.clear(stringstream::goodbit);
    ss<<line[i];
    for(int j=0;j<(l+1)/2;j++){
      k=0;
      ss>>k>>cc;
      if(i<=l/2)
	path[j+1][i]=max(path[j][i-1],path[j+1][i-1])+k;
      else
	path[j+1][i]=max(path[j+1][i-1],path[j+2][i-1])+k;
    }
  }
  cout<<path[1][l-1]<<endl;
  return 0;
}