a = []
zero = 0

am = 0
am_big = 0

for i in range(5):
    b = []
    x = int(input())

    am = x%10


    if(am_big < am):
        am_big = am
        am_big_key = i

    if(am == 0):
        b.append(0)
        zero += 1
    elif(am > 5):
        b.append(5-x%5)
    else:
        b.append(am)
    b.append(x)
    a.append(b)

sum = 0


#print(a[am_big_key])

sum = a[am_big_key][1] +a[am_big_key][0]


a.pop(am_big_key)

if(zero>0):
    a = sorted(a)
else:
    a = sorted(a, reverse=True)



for i in range(len(a)-1):
    #print(a[i])

    if(int(a[i][0]) == 0):
        sum += a[i][1]
    else:
        sum += a[i][1] + a[i][0]

sum += a[i+1][1]




print(sum)



