object Main extends App {
	val a = new Array[Int](5)
	val b = new Array[(Int, Int)](5)

	for(i<-0 until 5){
		a(i) = scala.io.StdIn.readInt

		if(a(i)%10 == 0) b(i) = (0, i)
		else b(i) = (10 - a(i)%10, i)
	}


	val c = b.sortBy(_._1)
	var ans = 0
	for(x<- c){
		ans += a(x._2) + x._1
	}

	println(ans - c(4)._1)

	

}