a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

aa = a % 10
bb = b % 10
cc = c % 10
dd = d % 10
ee = e % 10

cnt = 0

aaa = 10
bbb = 10
ccc = 10
ddd = 10
eee = 10
if aa != 0:
    cnt += 10
    aaa = aa
if bb != 0:
    cnt += 10
    bbb = bb
if cc != 0:
    cnt += 10
    ccc = cc
if dd != 0:
    cnt += 10
    ddd = dd
if ee != 0:
    cnt += 10
    eee = ee

if cnt > 0:
    cnt = cnt - 10
mmm = min([aaa, bbb, ccc, ddd, eee])

print(a - aa + b - bb + c - cc + d - dd + e - ee + cnt + mmm)