#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[101][101];
int hisi[101][101];
int main()
{
    int temp=0;
    char t;
    string s;
    vector<int> nums;
    while(cin>>s)
    {
        if(cin.eof())break;
        int len = s.size();
        for(int i=0;i<len;i++)
        {
            if(s[i]==','){nums.push_back(temp);temp=0;}
            else{temp= temp*10 +(int) s[i]-'0';}
        }
        nums.push_back(temp);
        temp=0;
    }
    //cout << nums.size()<<endl;
    int hen = (int)sqrt((double)nums.size());
    int dan = 0;
    int k=0,x=0,y=0;
    for(dan=0;dan<hen;dan++)
    {
        x=0;
        y=dan;
        while(1)
        {
            hisi[x][y] = nums[k];
            //cout << x<<","<<y << endl;
            k++;
            x++;
            y--;
            
            if(y<0)break;
        }
    }
    for(dan=hen;dan<2*hen-1;dan++)
    {
        y = hen -1;
        x = dan-hen+1;
        //for(int s = 0;s<dana+1;s++)
        while(1)
        {
            hisi[x][y] = nums[k];
            k++;
            x++;
            y--;
            if(x==hen)break;
        }
    }
    dp[0][0] = hisi[0][0];
    for(int i=1;i<hen;i++)
    {
        dp[0][i] = dp[0][i-1]+hisi[0][i];
        dp[i][0] = dp[i-1][0]+hisi[i-1][0];
    }
    for(int j=1;j<hen;j++)
    {
        for(int i=1;i<hen;i++)
        {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])+hisi[i][j];
        }
    }
    cout << dp[hen-1][hen-1]<<endl;
    //rep(j,hen){rep(i,hen){cout<<hisi[i][j];}cout<<endl;}
    return 0;
}