# -*- coding:utf-8 -*-
class Solution:
    def NumberOf1Between1AndN_Solution(self, n):
        # write code here
        ans = 0
        for x in range(1,n+1):
            if '1' in str(x):
                ans += str(x).count('1')
        return ans