import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    auto d = stdin.byLine().map!(s=>s.split(",").map!(to!int).array()).array();
    auto dp = d[0].dup;
    foreach(a;d[1..$])
    {
        auto dpn = new int[a.length];
        foreach(i;0..dp.length)
        {
            if(0<=i && i<dpn.length)
                dpn[i]=max(dpn[i],dp[i]+a[i]);
            auto j = i+(dpn.length-dp.length);
            if(0<=j && j<dpn.length)
                dpn[j]=max(dpn[j],dp[i]+a[j]);
        }
        swap(dp,dpn);
    }
    writeln(dp[0]);
}