lists = []
lists2 = []
a = int(input())
if a %10 == 0:
    lists2.append(a)
else:
    lists.append(a)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
time = 0
for t in lists2:
    time += t
for t in lists[0:len(lists)-1]:
    time += (10 - t%10) + t
time +=lists[-1]
print(time)