package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var a int
	var b int
	var c int
	var d int
	var e int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&e)
	var maxDiff int
	var maxDiffIndex int
	list := []int{a, b, c, d, e}
	for i, l := range list {
		f := calculateDiff(l)
		if i == 0 {
			maxDiff = 0
		} else {
			if maxDiff < f {
				maxDiff = f
				maxDiffIndex = i
			}
		}
	}
	var time int
	for i, l := range list {
		if i == maxDiffIndex {
			continue
		}
		time += l
		if time%10 != 0 {
			temp := 10 - time%10
			time += temp
		}
	}
	fmt.Println(time + list[maxDiffIndex])
}

func calculateDiff(a int) int {
	b := strings.Split(strconv.Itoa(a), "")
	c, _ := strconv.Atoi(b[len(b)-1])
	var result int
	if c == 0 {
		result = 0
	} else {
		result = 10 - c
	}
	return result
}
