Problem H

Count the Numbers

Input: standard input
Output: standard output

Time Limit: 2 seconds

 

You're given three non-negative integers N (0 <= N <= 999), A, B, (0 <= A <= B <= 2000000000). Count the number of integers in the interval [A; B] which contain N as a subsequence.

For example if N = 3, A = 3 and B = 17, there are two integers which contain N as a subsequence: 3 and 13.

 

Input

The input contains triples of numbers A, B and N. The input ends with "-1 -1 -1". This line should not be processed.

 

Output

For each triple, output the answer on a new line.

 

Sample Input                              Output for Sample Input

3 17 3
0 20 0
0 150 17
-1 -1 -1

2
3
2

 


Author: Slavi Marinov
Translation and solution: Petko Minkov