package main

import (
	"fmt"
)

func main() {
	// var a, b, c, d, e int
	// fmt.Scan(&a, &b, &c, &d, &e)
	ts := make([]int, 5)
	min := 1000000
	tmp := 1000000
	sum := 0
	for i := 0; i < 5; i++ {
		fmt.Scan(&ts[i])
		cal := (ts[i] + 9) % 10
		if cal <= tmp {
			min = ts[i]
			tmp = cal
		}
		sum += ts[i]
	}
	diff := diff(ts, min)

	sum += diff
	fmt.Print(sum)
}

func diff(ts []int, min int) int {
	f := false
	r := 0
	for _, t := range ts {
		if t == min && !f {
			f = true
			continue
		}
		x := 0
		for i := 1; i < 10; i++ {
			x = t + i
			if x%10 == 0 {
				r += x
				break
			}
		}
	}
	return r
}
