# coding: utf-8

import sys
input = sys.stdin.readline

times = []
for _ in range(5):
    x = int(input())
    times.append([x, ((x + 9) // 10 * 10) - x])

times.sort(key=lambda x : x[1])

ans = 0
for i in range(4):
    ans += times[i][0] + times[i][1]

ans += times[-1][0]

print(times)
print(ans)

