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

dish = [a,b,c,d,e]
result=0

mx=-1

def dtime(a):
    for i in range(9):
        if a%10==0:
            return a
        else:
            a+=1

for dd in dish:
    for i in range(0,10):
        if (dd+i) % 10 == 0:
            tmp=i
            break
    if tmp > mx:
        mx = tmp
        buf=dd

dish.remove(buf)

for dd in dish:
    result+=dtime(dd)

print(result+buf)
