def solution(storey):
answer = 0
while storey > 0:
tmp = storey % 10
storey //= 10
if tmp >= 6:
answer += (10 - tmp)
storey += 1
elif tmp == 5:
tmp1 = storey % 10
answer += tmp
if tmp1 >= 5:
storey += 1
else:
answer += tmp
return answer
PREVIOUS[백준] 색종이 만들기