import math
S = [input() for i in range(5)]
#合計時間
num = 0
#ポイント
point = int(S[0])
for i in range(1,5):
  if point[-1] == 0:
    num += point
    point = S[i]
  else:
    if point[-1] > int(S[i][-1]):
      num += point + 10 - point[-1]
      point = S[i]
    else:
      num += int(S[i]) +10 - intS[i][-1]
   
    
num += point

print(num)