CodeEff/ECCO huggingface dataset:
# Original solution
while 1:
    n,l = list(map(int,input().split()))
    if n == 0: break
    
    tube = [[] for i in range(l-1)]
    for i in range(1,n+1):
        d,p = input().split()
        tube[int(p)-1].append(i if d == "R" else -i)
    t = num = 0
    while sum(len(ele) for ele in tube) != 0:
        for s in [-1,1]:
            for i in range(l-1)[::s]:
                for a in tube[i]:
                    if -s*a > 0:
                        tube[i].remove(a)
                        if i == (l-2 if s == -1 else 0):
                            num = abs(a)
                        else:
                            tube[i-s].append(a)
        for i in range(l-1):
            if len(tube[i]) > 1:
                tube[i] = [-a for a in tube[i]]
        t += 1
    print(t,num)

# Optimized solution
while 1:
    n,l = list(map(int,input().split()))
    if n == 0: break
    R = [0]*(l-1)
    L = [0]*(l-1)
    for i in range(1,n+1):
        d,p = input().split()
        p = int(p)-1
        if d == "R": R[p] = i
        else: L[p] = i
    t = num = 0
    while sum(R)+sum(L) != 0:
        if R[-1] > 0: num = R[-1]
        R = [0]+R[:-1]
        if L[0]  > 0: num = L[0]
        L = L[1:]+[0]
        for i in range(l-1):
            if min(L[i],R[i]) > 0: R[i],L[i] = L[i],R[i]
        t += 1
    print(t,num)
# Original solution
N, A, B = list(map(int, input().split()))
ans = 0

for i in range(N+1):
    t_sum = 0
    for e in str(i):
        t_sum += int(e)
    if A<= t_sum <= B:
        ans += i
        
print(ans)

# Optimized solution
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
    if A <= sum(int(x) for x in str(i)) <= B:
        ans += i
print(ans)
# Original solution
a,b,c=list(map(int,input().split()))
count=0
for i in range(a+1):
    A=list(str(i))
    s=0
    for k in range(len(A)):
       s+=int(A[k]) 
    if b<=s<=c:
        count+=i
print(count)






# Optimized solution
N, A, B = list(map(int, input().split()))
print((sum(i for i in range(1, N+1) if A <= sum(map(int, str(i))) <= B)))
# Original solution
n, a, b = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
  if a <= sum(map(int, list(str(i)))) <= b:
    ans.append(i)
print((sum(ans)))

# Optimized solution
n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n+1):
  if a <= sum(map(int, list(str(i)))) <= b:
    ans += i
print(ans)
# Original solution
N, A, B = list(map(int, input().split()))
res = 0
for i in range(N+1):
    if A <= sum([int(s) for s in str(i)]) <= B:
        res += i
print(res)

# Optimized solution
n,a,b = list(map(int,input().split()))
s = 0
for i in range(n+1):
    if a <= sum([int(j) for j in str(i)]) <= b:
        s += i
print(s)
# Original solution
n,a,b = list(map(int,input().split()))
ans = 0

for i in range(n+1):
    keta_wa = 0
    x = i
    while x != 0:
        keta_wa += int(x % 10)
        x /= 10
        #print(keta_wa,x)
    
    if a <= keta_wa <= b:
        ans += i 

print(ans)

# Optimized solution
n,a,b = list(map(int,input().split()))
ans = 0

for i in range(n+1):
    keta_wa = 0
    x = i
    while x != 0:
        keta_wa += int(x % 10)
        x = int(x /10)
        #print(keta_wa,x)
    
    if a <= keta_wa <= b:
        ans += i 

print(ans)
# Original solution
a, b, c = list(map(int, input().split()))
y = 0

for x in range(a):
	if b <= sum(list(map(int, list(str(x+1))))) <= c:y += x + 1
print(y)

# Optimized solution
a, b, c = list(map(int, input().split()))
total = 0

for x in range(a+1):
  z = x
  d = 0
  while z != 0:
    d += z % 10
    z = z // 10
  if b <= d <= c:total += x
print(total)
# Original solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=list(map(int, input().split()))
    l=[]
    for i in range(1,n+1):
        cnt=0
        for j in range(len(str(i))):
            cnt+=int(str(i)[j])
        if a<=cnt<=b:
            l.append(i)
    print((sum(l)))
resolve()

# Optimized solution

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=list(map(int, input().split()))
    ans=0
    for i in range(1,n+1):
        cnt=0
        for j in str(i):
            cnt+=int(j)
        if a<=cnt<=b:
            ans+=i
    print(ans)
resolve()
# Original solution
def FindSumOfDigits(n):
    Sum=0
    while(n>0):
        Sum+=(int(n%10))
        n=n/10
    return Sum

N,A,B=list(map(int,input().split()))
ans=0
ans_list=[]
sumlist=[]
for i in range(1,N+1):
    sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

# Optimized solution
def FindSumOfDigits(n):
    Sum=0
    while(n>0):
        Sum+=(int(n%10))
        n=n/10
    return Sum

N,A,B=list(map(int,input().split()))
ans=0
#ans_list=[]
#sumlist=[]
for i in range(1,N+1):
    #sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        #ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)
# Original solution
def FindSumOfDigits(n):
    Sum=0
    while(n>0):
        Sum+=(int(n%10))
        n=n/10
    return Sum

N,A,B=list(map(int,input().split()))
ans=0
#ans_list=[]
#sumlist=[]
for i in range(1,N+1):
    #sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        #ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

# Optimized solution
N,A,B=list(map(int,input().split()))
cnt=0
for n in range(1,N+1):
    total=0
    total+=n%10
    total+=int(n/10)%10
    total+=int((n/10)/10)%10
    total+=int(((n/10)/10)/10)%10
    total+=int((((n/10)/10)/10)/10)%10
    if A<=total<=B:
        cnt+=n
print(cnt)
# Original solution
from functools import reduce

n,a,b = [int(x) for x in input().split(" ")]

ans = 0
for ni in range(a,n+1):
    if ni <= 9 :
        if a <= ni and ni <= b:
            ans += ni
    else:
        add_each_dig = reduce(lambda x, y: int(x) + int(y), str(ni) )
        if a <= add_each_dig and add_each_dig <= b:
            ans += ni

print(ans)

# Optimized solution
from functools import reduce

n,a,b = [int(x) for x in input().split(" ")]

ans = 0
for ni in range(a,n+1):
    add_each_dig = int(reduce(lambda x, y: int(x) + int(y), str(ni) ))
    if a <= add_each_dig and add_each_dig <= b:
        ans += ni

print(ans)
# Original solution
N, A, B = (int(x) for x in input().split())
Ans = [i if A <= sum(int(x) for x in list(str(i))) <= B else 0 for i in range(1,N+1)]
print((sum(Ans)))

# Optimized solution
def myfunc(A, B):
    def resfunc(x):
        if A <= sum(map(int,list(str(x)))) <=B:
            return x
        else:
            return 0
    return resfunc

N, A, B = list(map(int, input().split()))
print((sum(map(myfunc(A,B), list(range(1, N+1))))))
# Original solution
N, A, B = list(map(int, input().split()))
res = 0
for i in range(N+1):
    if A <= sum([int(s) for s in str(i)]) <= B:
        res += i
print(res)

# Optimized solution
N, A, B = list(map(int, input().split()))
def keta_sum(x):
    m = 0
    while x:
        m += x%10
        x //= 10
    return(m)
res = 0
for i in range(N+1):
    if A <= keta_sum(i) <= B:
        res += i
print(res)
# Original solution
# ABC083B - Some Sums

n, a, b = list(map(int, input().split()))
answer = 0

for i in range(n + 1):
    total = sum(list(map(int, list(str(i)))))
    if a <= total <= b:
        answer += i
    
print(answer)

# Optimized solution
# ABC083B - Some Sums
n, a, b = list(map(int, input().rstrip().split()))
total = 0
for i in range(1, n + 1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        total += i
print(total)
# Original solution
n,a,b = list(map(int,input().split()))
ans = 0
for i in range(n+1):
    c = sum(int(j) for j in str(i))
    if c >= a and c <= b:
        ans += i
print(ans)

# Optimized solution
n,a,b=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
    temp=0
    for j in str(i):
        temp+=int(j)
    if temp>=a and temp<=b:
        ans+=int(i)
print(ans)
# Original solution
def f(n):
    return sum([int(i) for i in str(n)])


N, A, B = list(map(int, input().split()))
L = [f(i) for i in range(1, 1 + N)]
print((sum([i + 1 for i, l in enumerate(L) if A <= l <= B])))


# Optimized solution
def f(n):
    return sum([int(i) for i in str(n)])


N, A, B = list(map(int, input().split()))
print((sum([i for i in range(1, 1 + N) if A <= f(i) <= B])))
# Original solution
n, a, b = list(map(int, input().split()))
result = 0
for i in range(1, n+1):
  total = 0
  t = i
  for j in range(5):
    total += t%10
    t = t // 10
  if a <= total <= b:
    result += i
print(result)


# Optimized solution
n, a, b = list(map(int, input().split()))
total = 0
for i in range(1, n+1):
  n = i
  tmp = 0
  while(n > 0):
    tmp += n % 10
    n = n // 10
  if a <= tmp <= b:
    total += i
print(total)
# Original solution
N,A,B = list(map(int, input().split()))
s = 0
for i in range(1,N+1):
    if A<=sum(map(int, str(i)))<=B:
        s+=i
print(s)

# Optimized solution
N,A,B = list(map(int, input().split()))
print((sum(i for i in range(1,N+1) if A<=sum(map(int, str(i)))<=B)))
# Original solution
import functools
n = list(map(int,input().split()))
ans = 0
for i in range(n[0]+1):
  s = list(map(int,str(i)))
  sum = functools.reduce(lambda a,b: a+b, s)
  if n[1]<= sum and sum <= n[2]:
    ans+=i
print(ans)

# Optimized solution
from functools import reduce
n = list(map(int,input().split()))
ans = 0
for i in range(n[0]+1):
  s = list(map(int,str(i)))
  sum = reduce(lambda a,b: a+b, s)
  if n[1]<= sum and sum <= n[2]:
    ans+=i
print(ans)
# Original solution
n, a, b = list(map(int, input().split()))
s = [0]*5
ans = 0
for i in range(n+1):
    s[0] = i // 10000
    s[1] = (i % 10000) // 1000
    s[2] = (i % 1000) // 100
    s[3] = (i % 100) // 10
    s[4] = (i % 10) // 1
    temp = s[0]*10000+s[1]*1000+s[2]*100+s[3]*10+s[4]

    if a <= sum(s) and sum(s) <= b:
        ans += temp
print(ans)

# Optimized solution
def sum_digits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum


n, a, b = list(map(int, input().split()))
s = [0]*5
ans = 0
for i in range(n+1):
    temp = sum_digits(i)
    if a <= temp and temp <= b:
        ans += i
print(ans)
# Original solution
def main():
    n, a, b = list(map(int, input().split()))

    sumv = 0
    for x in range(a, n+1):
        num = sum([int(i) for i in str(x)])
        if num >= a and num <= b: sumv += x
    print(sumv)


if __name__ == '__main__':
    main()

# Optimized solution
def sum_digit(x):
    sumv = 0
    while x > 0:
        t = x % 10
        sumv += t
        x = x // 10
    return sumv

if __name__ == '__main__':
    n, a, b = list(map(int, input().split()))

    ans = 0
    for num in range(a, n+1):
        sumv = sum_digit(num)
        if a <= sumv and sumv <= b:
            ans += num
    print(ans)
# Original solution
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
  if A <= sum([int(c) for c in str(i)]) <= B:
    ans += i
print(ans)

# Optimized solution
def digit_sum(x):
    res = 0
    while x != 0:
        res += x%10
        x //= 10
    return res
    
[N,A,B] = list(map(int,input().split()))
ans = 0
for i in range(1,N+1):
    if A <= digit_sum(i) <= B:
        ans += i
print(ans)
# Original solution
N, A, B = list(map(int, input().split()))

tot = 0
for i in range(1, N+1):
    s = 0
    for c in list(str(i)):
        s += int(c)
    if A<= s <=B:
        tot += i
print(tot)

# Optimized solution
N, A, B = list(map(int, input().split()))

tot = 0
for i in range(1, N+1):
    q = i
    s = 0
    while q > 0:
        q, r = divmod(q, 10) #;print(i, q, r, s)
        s += r       
    if A<= s <=B:        
        tot += i #;print(i)
        
print(tot)
# Original solution
def main():
    N, A, B = list(map(int,input().split()))
    #print('N:%d A:%d B: %d' % (N,A,B)) 

    answer = []
    for i in range(N+1):
        s = sum( map(int,list(str(i)) )) # list of int -> sum
        if s >= A and s <= B: answer.append(i)
        #print('i:%d s:%d' % (i,s))
    print((sum(answer)))

if __name__ == "__main__":
    main()

# Optimized solution
import sys
def main():
    input = sys.stdin.readline()
    N, A, B = list(map(int,input.split()))
    #print('N:%d A:%d B: %d' % (N,A,B)) 

    answer = []
    for i in range(N+1):
        s = sum( map(int,list(str(i)) )) # list of int -> sum
        if s >= A and s <= B: answer.append(i)
        #print('i:%d s:%d' % (i,s))
    print((sum(answer)))

if __name__ == "__main__":
    main()
# Original solution
x, min, max = input().rstrip().split()
digit = len(x)

ans = 0
i = int(x)
while i > 0:
    num = sum(list(map(int, str(i))))
    if int(min) <= num <=int(max):
        ans += i
    i = i - 1

print(ans)


# Optimized solution
x, min, max = input().rstrip().split()
ans = 0
i = int(x)
while i > 0:
    num = sum(list(map(int, str(i))))
    if int(min) <= num <=int(max):
        ans += i
    i = i - 1

print(ans)
# Original solution
x, min, max = input().rstrip().split()
ans = 0
for i in range(int(x) + 1):
    if int(min) <= sum(map(int, str(i))) <=int(max):
        ans += i
print(ans)


# Optimized solution
x, min, max = list(map(int, input().split()))
ans = 0
for i in range(x+1):
    if min <= sum(map(int, str(i))) <= max:
        ans += i
print(ans)
# Original solution

N, A, B = list(map(int, input().rstrip().split(' ')))
LIST_RESULT = []

for i in range(1, N+1):
    str_i = str(i)
    l = len(str_i)

    sum_tmp = 0
    for x in range(l):
        sum_tmp += int(str_i[x])
    if A <= sum_tmp and sum_tmp <= B:
        LIST_RESULT.append(i)

sum_result = sum(LIST_RESULT)
print(sum_result)


# Optimized solution
# coding: utf-8
"""this is python work script"""
def solve(N, A, B):
    LIST_RESULT = []
    for i in range(1, N + 1):
        str_i = str(i)
        l = len(str_i)

        sum_tmp = 0
        for x in range(l):
            sum_tmp += int(str_i[x])
        if A <= sum_tmp and sum_tmp <= B:
            LIST_RESULT.append(i)
    sum_result = sum(LIST_RESULT)
    return sum_result

def main():
    N, A, B = list(map(int, input().rstrip().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()
# Original solution
# coding: utf-8
"""this is python work script"""
def solve(N, A, B):
    LIST_RESULT = []
    for i in range(1, N + 1):
        str_i = str(i)
        l = len(str_i)

        sum_tmp = 0
        for x in range(l):
            sum_tmp += int(str_i[x])
        if A <= sum_tmp and sum_tmp <= B:
            LIST_RESULT.append(i)
    sum_result = sum(LIST_RESULT)
    return sum_result

def main():
    N, A, B = list(map(int, input().rstrip().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()


# Optimized solution
# coding: utf-8
"""this is python work script"""
def sum_num(i):
    sum_tmp = 0
    p = i
    for _ in range(5):
        p, mod = divmod(p, 10)
        sum_tmp += mod
        if p == 0:
           break
    return sum_tmp

def solve(N, num_min, num_max):
    """solve problem"""
    result = 0
    for i in range(1, N+1):
        sum_tmp = sum_num(i)
        if num_min <= sum_tmp and sum_tmp <= num_max:
            result += i
    return result

def main():
    N, A, B = list(map(int, input().rstrip().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()
# Original solution
n, a, b = list(map(int,input().split()))
ans = 0
for i in range(1, n + 1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)


# Optimized solution
n, a, b = list(map(int,input().split()))
ans = 0
for i in range(1, n + 1):
    sum = 0
    j = i
    while j != 0:
        sum += j % 10
        j = j // 10
    if a <= sum <= b:
        ans += i
print(ans)
# Original solution
# Problem: https://atcoder.jp/contests/abc083/tasks/abc083_b
# Python  1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def int2ketanowa(No):
    result = 0
    noStr = str(No)
    nolen = len(noStr)
    for j in range(0,nolen):
        result = result + int(noStr[j])
    return result

def solver(maxNum, upperNum, lowerNum):
    result = 0
    for j in range(1,maxNum+1,+1):
        sumKeta = int2ketanowa(j)
        if upperNum <= sumKeta and sumKeta <= lowerNum:
            result = result + j
    return result


if __name__ == "__main__":
    N, A, B = MI()
    print("{}".format(solver(N, A, B)))


# Optimized solution
# Problem: https://atcoder.jp/contests/abc083/tasks/abc083_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
intm1 = lambda x: int(x) - 1
intp1 = lambda x: int(x) + 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def digitSum(target):
    result = 0
    strTarget = str(target)
    for j in range(0, len(strTarget)):
        result = result + int(strTarget[j])
    return result


def checker(target, fromNumber, toNumber):
    result = False
    x = digitSum(target)
    if fromNumber <= x :
        if  x <= toNumber :
            result = True
    return result


def solver(maxNumber, fromNumber, toNumber):
    result = 0
    for j in range(1, maxNumber + 1):
        if checker(j, fromNumber, toNumber):
#            print("{} is check!".format(j))
            result = result + j
    # algorithm
    return result


if __name__ == "__main__":
    N, A, B = MI()
    print("{}".format(solver(N, A, B)))
# Original solution
n_a_b = list(map(int,input().split()))

ans = 0
plus = 0

for i in range(0,n_a_b[0]+1,1):
    num = i
    for j in range(5):
        plus = plus + num % 10
        num = int(num /10) 
        if i < 0:
            break

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

    plus = 0

print(ans)

# Optimized solution
n_a_b = list(map(int,input().split()))

ans = 0
plus = 0

for i in range(0,n_a_b[0]+1,1):
    num = i

    for j in range(5):
        plus = plus + num % 10
        num = int(num /10) 

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

    plus = 0

print(ans)
# Original solution
n, a, b = list(map(int, input().split()))

digit_sum_sum = 0
for num in range(1,n+1):
    digit_sum = 0
    for i in str(num):
        digit_sum += int(i)
    if a <= digit_sum <= b:
        digit_sum_sum += num
print(digit_sum_sum)


# Optimized solution
n,a,b = list(map(str,input().split()))
# al = list(map(int,input().split()))
a = int(a)
b = int(b)

lst = []
for x in range(1,int(n)+1):
    total = 0
    for i in str(x):
        total += int(i)
    if a <= total <= b:
        lst.append(x)

print((sum(lst)))
# Original solution
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
    x = (sum(list(map(int, list(str(i))))))
    if A <= x <= B:
        ans += i
print(ans)

# Optimized solution
N, A, B = list(map(int, input().split()))
ans = 0


def sumDigits(n):
    sum = 0
    while n != 0:
        sum += n % 10
        n = n // 10
    return sum


for i in range(N+1):
    x = sumDigits(i)
    if A <= x <= B:
        ans += i

print(ans)
# Original solution
N, A, B = list(map(int, input().split()))
m = 0
for n in range(1, N + 1):
    C = []
    n1 = n
    for k in range(4, -1, -1):
            C.append(int(n1 / (10 ** k)))
            n1 -= C[4 - k] * (10 ** k)
    if A <= sum(C) <= B:
        m += n
print(m)


# Optimized solution
n, a, b = list(map(int, input().split()))
ans = 0

for k in range(1, n+1):
    if a <= sum(map(int, str(k))) <= b:
        ans += k
print(ans)
# Original solution
N, A, B = list(map(int, input().split()))
n = []

for i in range(1, N+1):
  a = 0
  for x in range(len(str(i))):
    a += int(str(i)[x])
  if a >= A and a <= B:
    n.append(i)
print((sum(n)))

# Optimized solution
N, A, B = list(map(int, input().split()))

ans = 0
for i in range(1, N+1):
  a = list(str(i))
  c = 0
  for j in range(len(a)):
    c += int(a[j])
  if A <= c <= B:
    ans += i
print(ans)
# Original solution
n,a,b=list(map(int,input().split()))

ans=0
for i in range(1,n+1):
    if a<=sum(map(int,list(str(i))))<=b:
        ans+=i
print(ans)

# Optimized solution
n,a,b=list(map(int,input().split()))

print((sum(i for i in range(n+1) if a<=sum(map(int,str(i)))<=b)))
# Original solution
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(N+1):
    lis = [int(i) for i in str(i)]
    if A <= sum(lis) <= B:
        num = ""
        for j in lis:
            num += str(j)
        ans += int(num)
print(ans)

# Optimized solution
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1,N+1):
    if A <= sum([int(x) for x in str(i)]) <= B:
        ans += i
print(ans)
# Original solution
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, a, b = (int(x) for x in sys.stdin.read().split())
    total = 0
    for i in range(1, n+1):
        s = sum(list(int(x) for x in str(i)))
        if a <= s <= b: total += i
    print(total)

if __name__ == "__main__":
    # execute only if run as a script
    main()


# Optimized solution
import sys

n, a, b = list(map(int, sys.stdin.readline().split()))

def main():
    res = 0
    for i in range(1, n+1):
        s = sum([int(d) for d in str(i)])
        if a <= s <= b:
            res += i
    return res
    
if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
ans=0
n,a,b=list(map(int,input().split()))
for i in range(1,n+1):
    s=list(str(i))
    s1=list(map(int, list(s)))
    tmp=sum(s1)
    if a<=tmp<=b:
        ans+=int("".join(s))
print(ans)

# Optimized solution
n,a,b=list(map(int,input().split()))
print((sum(i for i in range(n+1) if a<=sum(map(int,str(i)))<=b)))
# Original solution
n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    s = sum(list(map(int, list(str(i)))))
    if a <= s and s <= b:
        ans += i
print(ans)


# Optimized solution
n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    j = i
    d = 0
    while j != 0:
        d += j % 10
        j //= 10
    if a <= d and d <= b:
        ans += i
print(ans)
# Original solution
n,a,b=list(map(int,input().split()))
ans = 0
l = list(range(1, n+1))

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

# print(digitSum(123))
# => 6
# print(digitSum(35829))
# => 27

for i in l:
    if a <= digitSum(i) <= b:
        ans = ans + i
print(ans)




# Optimized solution
n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n+1):
    if a <= sum([int(c) for c in str(i)]) <= b:
        ans += i
print(ans)
# Original solution
length,mi,ma = list(map(int,input().split()))
summ = 0
for i in range(1,length + 1):
  digits = len(str(i))
  digits_summary = 0
  
  for j in range(digits):
    digits_summary += int(str(i)[j])
  
  if mi<=digits_summary and digits_summary<=ma:
    summ += i
  else:
    pass
print(summ)

# Optimized solution
length,mi,ma = list(map(int,input().split()))
summ = 0
for i in range(1,length + 1):
  s = str(i)
  arr = list(map(int,s))
  su = sum(arr)
  if(su <= ma and su >= mi):
    summ += i
print(summ)
# Original solution
import math

n, a, b = list(map(int, input().split()))

sum_all = 0
for i in range(1, n + 1):
    sum_n = 0
    m = i
    while(m > 0):
        sum_n += math.floor(m % 10)
        m /= 10
    if a <= sum_n <= b:
        sum_all += i

print(sum_all)

# Optimized solution
n, a, b = list(map(int, input().split()))
sum_all = 0
for i in range(1, n + 1):
    m = str(i)
    sum_m = 0
    for j in range(len(m)):
        sum_m += int(m[j])
    if a <= sum_m <= b:
        sum_all += i
print(sum_all)