from collections import defaultdict as ddic
from collections import deque
from itertools import combinations, permutations, product
import bisect
import heapq
import math
import sys

stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

a = rri()
b = rri()
c = rri()
d = rri()
e = rri()

lst = [[a,-1],[b,-1],[c,-1],[d,-1],[e,-1]]

lst2 = []

for i, num in enumerate(lst):
    lst[i][1] = num[0] % 10

lst.sort(key=lambda arr: arr[1])

for i, l in enumerate(lst):
    if l[1] != 0:
        if i == 4:
            d1 = [item[0] for item in lst]
            print(sum(d1))
            break
        else:
            for j, k in enumerate(lst[i+1:]):
                lst[i+j+1][0] += (10 - lst[i+j+1][1])

            d2 = [item[0] for item in lst]
            print(sum(d2))
            break