#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

vector<int> split(string s) {
  vector<int> v;
  int old = 0;
  while(true) {
    int pos = s.find(',', old);
    v.push_back(stoi(s.substr(old)));
    if (pos == string::npos) {
      return v;
    } else {
      old = pos + 1;
    }
  }
}

int main() {
  int a[100][100];
  string s[100];
  int i = 0;
  while(cin) {
    cin >> s[i];
    ++i;
  }
  i--;
  int n = (i + 1) / 2;
  for (int j = 0; j < n; ++j) {
    auto v = split(s[j]);
    for (int k = 0; k <= j; ++k) {
      a[j-k][k] = v[k];
    }
  }
  for (int j = n; j < i; ++j) {
    auto v = split(s[j]);
    for (int k = 0; k <= i - j - 1; ++k) {
      a[n-k-1][j-n+1+k] = v[k];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if(i>0&&j>0)
        a[i][j] = max(a[i-1][j],a[i][j-1])+a[i][j];
      else if(i>0)
        a[i][j] = a[i-1][j]+a[i][j];
      else if(j>0)
        a[i][j] = a[i][j-1]+a[i][j];
    }
  }
  cout << a[n-1][n-1] << endl;
  return 0;
}