#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int dp[130][130];//i段目j個目まで選んだ時の最大値
string str1;
vector<vector<int> > data;
int main()
{
  memset(dp,0,sizeof(dp));
  while(cin>>str1){
    replace(str1.begin(),str1.end(),',',' ');
    vector<int> v;
    stringstream ss(str1);
    while(ss>>str1){
      v.push_back(atoi(str1.c_str()));
    }
    data.push_back(v);
  }

  dp[0][0] =data[0][0];
  for(int i = 1;i <data.size();i++){
    for(int j = 0;j <data[i].size();j++){
      if(i <=data.size()/2)
	dp[i][j] =max(dp[i-1][j-1],dp[i-1][j])+data[i][j];
      else
	dp[i][j] = max(dp[i-1][j],dp[i-1][j+1])+data[i][j];
    }
  }
  cout <<dp[data.size()-1][0]<<endl;

  return 0;
}