
list = [int(input()) for i in range(5)]
kList = []
for j in range(0,10):
    for i in list:
         if (i+j) % 10 == 0:
            if i % 10 != 0:
                kList.append(i+j) 
            else:
                kList.append(i)

nList = [i for i in kList[0:len(kList)-1]]
print(sum(nList) + kList[-1])