#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
  int point[100][100], path = 0;
  string s;
  while (getline(cin, s)) {
    for (int i = 0; i < s.size(); i++)
      s[i] = (s[i] == ',' ? ' ' : s[i]);
    stringstream ss(s);
    int tmp;
    int i = 0;
    while (ss >> tmp)
      point[path][i++] = tmp;
    path++;
  }

  for (int i = 1; i < path; i++)
    for (int j = 0; j < i+1; j++)
      if (i <= path / 2) {
        if (j-1 < 0)
          point[i][j] += point[i-1][j];
        else if (j == i)
          point[i][j] += point[i-1][j-1];
        else if (point[i-1][j] > point[i-1][j-1])
          point[i][j] += point[i-1][j];
        else
          point[i][j] += point[i-1][j-1];
      } else {
        if (point[i-1][j] > point[i-1][j+1])
          point[i][j] += point[i-1][j];
        else
          point[i][j] += point[i-1][j+1];
      }
  cout << point[path-1][0] << endl;
  return 0;
}