import numpy as np
data='''4445,2697,5115,718,2209,2212,654,4348,3079,6821
1096,20,1318,7586,5167,2642,1443,5741,7621,7030
9607,7385,521,6084,1364,8983,7623,1585,6935,8551
7206,3114,7760,1094,6150,5182,7358,7387,4497,955
3620,8024,577,9997,7377,7682,1314,1158,6282,6310
1074,5438,9008,2679,5397,5429,2652,3403,770,9188
4248,2493,4361,8327,9587,707,9525,5913,4295,1176
5596,1521,3061,9868,7037,7129,8933,6659,5947,5063
3653,9447,9245,2679,767,714,116,8558,163,3927
8779,158,5093,2447,5782,3967,1716,931,7772,8164'''
data=data.split('\n')
data=[i.split(',') for i in data]
data=np.array(data,dtype=np.int64)
def min_road(data=data):
	a=[-1,0,1]
	for i in range(1,np.shape(data)[0]):
		for j in range(0,np.shape(data)[1]):
			min_now=[]
			for k in a:
				if 0<=j+k<np.shape(data)[0]:
					min_now.append(data[i-1,j+k])
			data[i,j]+=min(min_now)
	return data
lenth=min_road()
print(lenth[np.shape(data)[0]-1].min())


