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 = 10:
  e = 10
  
list1 = [a,b,c,d,e]
list1.sort(reverse = True)
key = {a:A,b:B,c:C,d:D,e:E}
i = 0
sum = 0
while i < 4:
  sum += key[list1[i]]
  while not sum % 10 == 0:
    sum += 1
  i += 1
  
sum += list1[4]
print(sum)
  