#include <bits/stdc++.h>
using namespace std;

vector<int> split(const string &str, char sep) {
  vector<int> v;
  stringstream ss(str);
  string buffer;
  while( getline(ss, buffer, sep) ) {
    v.push_back(stoi(buffer));
  }
  return v;
}

int main() {
  vector<vector<int>> dp;
  string s;
  while (cin >> s) {
    vector<int> v = split(s, ',');
    dp.push_back(v);
  }
  for (int i = 0; i < dp.size() - 1; ++i) {
    for (int j = 0; j < dp[i + 1].size(); ++j) {
      if (i >= dp.size() / 2) {
        dp[i + 1][j] += max(dp[i][j], dp[i][j + 1]);
      } else {
        if (j == 0) {
          dp[i + 1][j] += dp[i][j];
        } else if (j == dp[i + 1].size() - 1) {
          dp[i + 1][j] += dp[i][j - 1];
        } else {
          dp[i + 1][j] += max(dp[i][j - 1], dp[i][j]);
        }
      }
    }
  }
  cout << dp[dp.size() - 1][0] << endl;
  return 0;
}

