import itertools

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
array = [A, B, C, D, E]
min_time= float('inf')

for i in list(itertools.permutations(array)):
    tmp = i[0] + ((10 - i[0]%10) if i[0] % 10 != 0 else 0)
    tmp += i[1] + ((10 - i[1]%10)  if i[1] % 10 != 0 else 0)
    tmp += i[2] + ((10 - i[2]%10) if i[2] % 10 != 0 else 0)
    tmp += i[3] + (10 - i[3]%10)
    tmp += i[4]
    
    min_time = min(min_time, tmp)
    
print(min_time)