# -*- coding: utf-8 -*-

n = 5
s = []
lastS = []
for i in range(n):
    s.append(raw_input())
    lastS.append(int(s[i][-1]))

# 1の位が0でなく最も少ないメニューを探す
min = 9
minMenu = 0
for i in range(n):
    if lastS[i] < min and lastS[i] != 0:
        minMenu = i
        min = lastS[i]

# 時間を計算する
ans = 0
for i in range(n):
    if i != minMenu:
        if lastS[i] != 0:
            ans += (int(s[i]) - lastS[i]) + 10
        else:
            ans += int(s[i])
    else:
        ans += int(s[i])

print ans

    
