a=0
arr=[]
while s=gets
  arr[a]=s.split(",").map{|x|x.to_i}
  a+=1
end
#p arr
S=[]
S[0]=[arr[0][0]];
for i in 1..a do
	S[i]=[]
	if i<=a/2
		for j in 0..i do
			x=0;y=0
			if !(j-1<0) then x=S[i-1][j-1] end
			if j<i then y=S[i-1][j] end
			S[i][j]=([x,y].max)+arr[i][j]
			#p S
		end
	else
		for j in 0..a-i-1 do
			x=S[i-1][j+1]
			y=S[i-1][j]
			S[i][j]=([x,y].max)+arr[i][j]
			#p S
			end
		end
end

puts S[a-1]