a = gets().to_i
b = gets().to_i
c = gets().to_i
d = gets().to_i
e = gets().to_i

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

mintime = 9999
arr.permutation(5).each {|a|
	t = 0
	(0 ... a.length).each {|i|
		t += a[i]
		t += 10 - a[i] % 10 if i < a.length - 1 if a[i] % 10 > 0
	}

	mintime = t if mintime > t
}

puts mintime
