A=[]
Y = []
for i in range(5):
    x = int(input())
    y = x % 10
    A.append((y,x))
    Y.append(y)

sum = 0
f = 0
if Y[0] == Y[1] and Y[1] == Y[2] and Y[2] == Y[3] and Y[3] == Y[4] :
    for i in range(len(A)):
        y,x = A[i]
        A[i] = (x,y)
    f = 1
A = sorted(A)
for i in range(len(A)):
    y,x = A[len(A)-1-i]
    if i == len(A)-1:
        if f == 1:
            sum += y
        else:
            sum += x
    else:
        if f == 1:
            sum += y + (10-x)
        else:
            sum += x + (10-y)

print(sum)
