time=Array.new(5)
sa=Array.new(5)
sa_num=Array.new(5)
5.times do|i|
	time[i]=gets.to_i
	sa[i]=(10-time[i]%10)
	sa[i]=0 if sa[i]==10
	sa_num[i]=i
end
sa.sort!
for i in 0..3
	indexmin=i
	for j in i+1..4
		if sa[indexmin]>sa[j] and sa[indexmin]!=0
			indexmin=j
		end
	end
	w=sa[indexmin]
	sa[indexmin]=sa[i]
	sa[i]=w

	w=sa_num[indexmin]
	sa_num[indexmin]=sa_num[i]
	sa_num[i]=w
end
sum=0
4.times do|i|
	sum+=time[sa_num[i]]
	sum+=sa[i]
end
sum+=time[sa_num[4]]
p sum