#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int s[111][111];
int main(void){
  int a,k;
  for(k = 0; cin >> a; k++){
    s[k][0] = a;
    for(int i = 1; getchar()==','; i++){
      cin >> s[k][i];
    }
  }

  int n=2,p=1;
  //cout << s[0][0] << endl;
  for(int i = 1; i < k; i++){
    for(int j = 0; j < n; j++){
      a = 0;
      if(k/2 >= i && j > 0) a = max(a,s[i-1][j-1]);
      if(k/2 < i && j+1 < p) a = max(a,s[i-1][j+1]);
      if(j < p) a = max(a,s[i-1][j]);
      s[i][j] += a;
      //cout << s[i][j] << ",";
    }
    //cout << endl;
    p = n;
    n += (k/2>i)?1:-1;
  }
  cout << s[k-1][0] << endl;
}