
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


orders = [a,b,c,d,e]

def nokori(az, sitei):
	tmp = []
	for a in az:
		if a != sitei:
			tmp.append(a)
	return tmp

def calcOrder(order):
	time = 0
	for o in order:
		if time % 10 != 0:
			time += 10 - time % 10
		time += o
	return time

time = 0
mintime = 1000
res = ''

for fst in orders:
	
	az = nokori(orders, fst)
	for sec in az:
		ax = nokori(az, sec)
		for thd in ax:
			aw = nokori(ax, thd)
			for fth in aw:
				af = nokori(aw, fth)
				for fif in af:
					time = calcOrder([fst,sec,thd,fth,fif])
					if time < mintime:
						mintime = time
						res = str([fst,sec,thd,fth,fif])

print(mintime)
