#P10959. Moon Numbers

    ID: 13007 Type: Default 1000ms 256MiB

Moon Numbers

Moon Numbers

A decimal number is called a "Moon Number" if it is divisible by the sum of its digits. For example, consider the number \(n\) and let \(S(n)\) be the sum of its digits. Then \(n\) is a Moon Number if and only if \(n \bmod S(n) = 0\).

You are given two integers \(L\) and \(R\). Your task is to count how many Moon Numbers exist in the closed interval \([L,R]\).

inputFormat

The input consists of a single line containing two space-separated integers \(L\) and \(R\) (\(1 \leq L \leq R \leq 10^{12}\)).

outputFormat

Output a single integer: the number of Moon Numbers in the interval \([L,R]\).

sample

1 10
10