A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
Data = [A, B, C, D, E]
a, b, c, d, e =  A % 10, B % 10, C % 10, D % 10, E % 10,
d_data = [a, b, c, d, e]
h = d_data.count(0)
time_data = []
j = 5 - h
while h >= 1:
    i = d_data.index(0)
    time_data.append(Data[i])
    del d_data[i]
    del Data[i]
    h = h - 1
while j >= 2:
    k = d_data.index(max(d_data))
    time_data.append(Data[k] + (10 - d_data[k]))
    del d_data[k]
    del Data[k]
    j = j - 1

time_data.append(Data[0])
print(sum(time_data))
