#include <iostream>
#include <cstdlib>
using namespace std;
int a[1001][1001]={};
int dp[1001][1001]={};
int m=0,maxsize=0;
void solve() {
  for(int j=0;j<=m/2;j++) {
    dp[0][j] = 0;
  }

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

int main() {
  string str;
  int size;
  while(true) {
    getline(cin,str);
    if(cin.eof()) break;
    size = (str.size() + 1 ) / 2;
    int to1=0,to2=str.find(',',to1);
    if(to2 == -1) to2 = str.size()-1;
    for(int i=0;i<size;i++) {
      to2=str.find(',',to1+1);
      if(to2 == -1) to2 = str.size()-1;
      a[m][i] = atoi(str.substr(to1 ,to2-to1+1).c_str());
      to1 = to2+1;
    }
    m++;
  }
  solve();
}