dmd = []
cnt = 0
while l = gets
  dmd[cnt] = l.split(",").map(&:to_i)
  cnt += 1
end
s = Array.new(cnt){ Array.new(cnt, 0) }
s[0][0] = dmd[0][0]
(1..cnt/2).each do |i|
  (i+1).times do |j|
    a = b = 0
    a = s[i-1][j-1] if j - 1 >= 0
    b = s[i-1][j] if j < i
    s[i][j] = ([a,b].max) + dmd[i][j]
  end
end
(cnt/2+1..cnt).each do |i|
  (cnt-i).times do |j|
    a = s[i-1][j+1]
    b = s[i-1][j]
    s[i][j] = ([a,b].max) + dmd[i][j]
  end
end
p s[cnt-1][0]