a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = 0
g = 0
h = 0
i = 0
j = 0
for k in range(9):
    if (a + f) % 10 != 0:
        f += 1
    if (b + g) % 10 != 0:
        g += 1
    if (c + h) % 10 != 0:
        h += 1
    if (d + i) % 10 != 0:
        i += 1
    if (e + j) % 10 != 0:
        j += 1
print(a+b+c+d+e+f+g+h+i+j-max(f,g,h,i,j))
print(f,g,h,i,j) 