import numpy as np
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

order_time = [A,B,C,D,E]
elapsed_time=0
extra = []
for i in order_time:
    ex = i%10
    extra.append(ex)
seiri = np.vstack((order_time,extra))
sort = np.sort(seiri)[:,::-1]
sort1 = sort[0]
sort2 =sort[1]
time = []
for i in range(0,len(sort)):
    ort = sort2[i]
    otime=sort1[i]+(10-ort)
    elapsed_time+=otime
elapsed_time+=sort1[-1]
print(elapsed_time)