def count_number1(s): count = 0 # 当前处理的位数是个位/十位/百位 factor = 1 # 如果还有其他的位数将一直执行,直到数位小于本来的数 while factor <= s : # 求数字的高位: high = s//(factor*10) # 求处理的低位 low = s%factor # 求当前的位是多少 current = (s//factor)%10 if current == 0: # 当前数为0,但是也许高位有1影响,因此,贡献的“1”数量为high * factor count += factor*high elif current == 1: count += high * factor + low + 1 else: count+=(high+1)*factor factor*=10 return count num_target = int(input()) print(count_number1(num_target))