read n a b
ans=0
for (( k = 1; k <= n; k++ )); do
    k4=$( printf %04d $k )
    sum=$(( ${k4:0:1} + ${k4:1:1} + ${k4:2:1} + ${k4:3:1} ))
    (( sum >= a && sum <= b )) && (( ans += k ))
done
echo ${ans}
