#include <bits/stdc++.h>
using namespace std;
//    std::sort(a.begin(), a.end(), std::greater<int>() );
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

using namespace std;
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}

int main()
{
    string input;
    vector<vector<int>> data;
    vector<vector<int>> memo;
    while (cin >> input)
    {
        vector<int> hoge;
        vector<int> m;
        for (const std::string &s : split(input, ','))
        {
            hoge.push_back(stoi(s));
            m.push_back(0);
        }
        data.push_back(hoge);
        memo.push_back(m);
    }
    memo[0][0] = data[0][0];
    REP(i, 1, data.size())
    {
        rep(j, data[i].size())
        {
            if (i <= (data.size() / 2))
            {
                if (j == 0)
                    memo[i][j] = memo[i - 1][j] + data[i][j];
                else if (data[i - 1].size() == j)
                    memo[i][j] = memo[i - 1][j - 1] + data[i][j];
                else
                    memo[i][j] = max(memo[i - 1][j] + data[i][j], memo[i - 1][j - 1] + data[i][j]);
            }
            else
            {
                memo[i][j] = max(memo[i - 1][j] + data[i][j], memo[i - 1][j + 1] + data[i][j]);
            }
        }
    }
    cout << memo[memo.size() - 1][memo[memo.size() - 1].size() - 1] << endl;
    return 0;
}