#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

int H;
int W[100];
int G[100][100];
int dp[100][100];

int solve() {
  dp[0][0] = G[0][0];
  for(int i = 1; i < H; ++i) {
    for(int j = 0; j < W[i]; ++j) {
      if(i <= H/2+1) {
	dp[i][j] = dp[i-1][j]+G[i][j];
	if(j-1 >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+G[i][j]);
      } else {
	dp[i][j] = max(dp[i-1][j], dp[i-1][j+1]) + G[i][j];
      }
    }
  }
  return dp[H-1][0];
}

int main() {
  H = 0;
  string line;
  while(getline(cin, line)) {
    W[H] = 0;
    replace(line.begin(), line.end(), ',', ' ');
    stringstream ss;
    ss << line;
    while(ss >> G[H][W[H]]) ++W[H];
    ++H;
  }
  cout << solve() << endl;
  return 0;
}