A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

if a == 0:
    a = 10
elif b == 0:
    b = 10
elif c == 0:
    c = 10
elif d == 0:
    d = 10
elif e == 0:
    e = 10


key = {a:A,b:B,c:C,d:D,e:E}
list_ = [a,b,c,d,e]
list_.sort(reverse = True)


i = 0
sum = 0
while i < 4:
    sum += key[list_[i]]
    while not sum % 10 == 0:
        sum += 1
    i += 1

sum += key[list_[4]]
print(sum)