A=[]

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

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

print(sum)
