Scanf.scanf "%d %d %d" (fun n a b ->
    let digit k =
        let rec loop i acc =
            if i = 0 then acc else loop (i / 10) (acc + (i mod 10))
        in
        loop k 0
    in
    let rec loop i acc =
        if i > n then acc else
            let d = digit i in
            loop (i + 1) (if d >= a && d <= b then acc + i else acc)
    in
    loop 1 0 |> Printf.printf "%d\n"
)