#P297. 【例50.3】 平衡数

【例50.3】 平衡数

Description

A balanced number is a positive integer xx where each digit dd appears exactly dd times in xx. For example, x=122x=122 is a balanced number because:
For the hundreds digit d=1d = 1, the digit 11 appears exactly 11 time in 122122, satisfying the condition;
For the tens digit d=2d = 2, the digit 22 appears exactly 22 times in 122122, satisfying the condition;
For the ones digit d=2d = 2, the digit 22 appears exactly 22 times in 122122, satisfying the condition;
Since every digit in 122122 satisfies the condition, 122122 is a balanced number.
Given two positive integers ll and rr (lrl≤r), please help calculate the sum of all balanced numbers between ll and rr.

Input Format

One line containing two positive integers ll and rr (1lr100001≤l≤r≤10000), separated by a space.

Output Format

One line containing a single integer, representing the sum of all balanced numbers between ll and rr.

Sample

1 25
23