a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cnt = 0
L = [a,b,c,d,e]
L1 =set(L)
l =[]
if len(L1) == 1:
    cnt += 4 * (10 - L[0] % 10) + sum(L)
    print(cnt)
    exit()
for i in L:
    if len(str(i)) == 1:
        cnt += 10-i
    elif i%10 == 0:
        cnt += 0
    elif i%10 > 5:
        cnt += 10- i%10
    elif i%10 <= 5:
        l.append(i)
print(sum(L) + cnt)