You are on page 1of 1

import sys

for f in range(1,110):
n=int(input())
tries = 0
k=n
count=0
if n == 0:
print(0)
else:
while(n>0):
count=count+1
n=n//10

while (((k-(k%10**(count-1)))/10**int((count-1))) % 2) == 0:
count = count - 1

if (((k-(k%10**(count-1)))/10**int((count-1))) % 2) == 1 and k
%10**(count-1)<5*10**(count-2) and count != 0 and k != 0:

tries = tries + k%10**(count-1)

tries = tries+((10**(count-1))+8)/9
print("Case #"+str(f)+": "+str(int(tries)))

elif count != 0 and k != 0:


tries = (((k-(k%10**(count-1)))/10**int((count-1)))
+1)*(10**(count-1))-k

print("Case #"+str(f)+": "+str(int(tries)))


else:
print("Case #"+str(f)+": "+str(int(tries)))