#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string in;
  vector< vector<int> > data;
  while(getline(cin, in)) {
    replace(all(in), ',', ' ');
    stringstream ss(in);
    vector<int> col;
    int num;
    while(ss >> num) col.push_back(num);
    data.push_back(col);
  }

  int dp[101][101] = {0};
  dp[0][0] = data[0][0];
  int mid = data.size() / 2;
  reps(i, 1, data.size()) rep(j, data[i].size()) {
    if(i <= mid) dp[i][j] = max(dp[i-1][j], (j > 0 ? dp[i-1][j-1] : 0LL));
    else dp[i][j] = max(dp[i-1][j], (j+1 < data[i].size() ? dp[i-1][j+1] : 0LL));
    dp[i][j] += data[i][j];
  }
  cout << dp[data.size()-1][data.back().size()-1] << endl;

  return 0;
}