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

if a%10 == 0:
    aa = 0
else:
    aa = 10-a%10
if b%10 ==0:
    bb = 0
else:
    bb = 10-b%10
if c%10 == 0:
    cc = 0
else:
    cc = 10-c%10
if c%10 == 0:
    cc = 0
else:
    dd = 10-d%10
if e%10 == 0:
    ee = 0
else:
    ee = 10-e%10

lastorder = max(aa,bb,cc,dd,ee)

if(aa == lastorder):
    ans = b+bb+c+cc+d+dd+e+ee+a
elif(bb == lastorder):
    ans = a+aa+c+cc+d+dd+e+ee+b
elif(cc == lastorder):
    ans = a+aa+b+bb+d+dd+e+ee+c
elif(dd == lastorder):
    ans = a+aa+b+bb+c+cc+e+ee+d
elif(ee == lastorder):
    ans = a+aa+b+bb+c+cc+d+dd+e

print(ans)
