#P4127. Divisible by Digit Sum Count

    ID: 17375 Type: Default 1000ms 256MiB

Divisible by Digit Sum Count

Divisible by Digit Sum Count

Given two integers \(a\) and \(b\), count how many numbers in the interval \([a, b]\) have the property that the sum of their digits divides the number itself. In other words, for each number \(n\) in \([a, b]\), let \(S(n)\) be the sum of its digits. You need to count the numbers for which \(S(n)\) is a divisor of \(n\) (i.e. \(n \bmod S(n) = 0\)).

inputFormat

The input consists of a single line containing two space-separated integers \(a\) and \(b\) with \(a \le b\).

outputFormat

Output a single integer representing the count of numbers in the range \([a, b]\) that satisfy the condition that the sum of their digits divides the number.

sample

1 20
13