import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = list(str(a))
B = list(str(b))
C = list(str(c))
D = list(str(d))
E = list(str(e))

S = []
sum = 0
if A[-1] == "0":
  sum += a
else:
  S.append(A[-1])
  if len(A) == 1:
    sum += 10
  else:
    sum += a + (10 - int(A[-1]))

if B[-1] == "0":
  sum += b
else:
  S.append(B[-1])
  if len(B) == 1:
    sum += 10
  else:
    sum += b + (10 - int(B[-1]))

if C[-1] == "0":
  sum += c
else:
  S.append(C[-1])
  if len(C) == 1:
    sum += 10
  else:
    sum += c + (10 - int(C[-1]))

if D[-1] == "0":
  sum += d
else:
  S.append(D[-1])
  if len(D) == 1:
    sum += 10
  else:
    sum += d + (10 - int(D[-1]))

if E[-1] == "0":
  sum += e
else:
  S.append(E[-1])
  if len(E) == 1:
    sum += 10
  else:
    sum += e + (10 - int(E[-1]))

if len(S) != 0:
  k = np.argmin(S)
  
  sum += int(S[k]) - 10
print(sum)