n = int(input())
c = 0
# 循环1~n
for i in range(1, n + 1):
# 对每个1~n的数拆位,看有多少个1,c+=1
while i > 0:
s = i % 10
if s == 1:
c += 1
i //= 10
print(c)
/**************************************************************
Problem: 1448
User: admin
Language: Python
Result: Accepted
Time:217 ms
Memory:34244 kb
****************************************************************/