You are on page 1of 2

369 Problem

A number is said to be a 369 number if the count of 3s is equal to count of 6s and the count of
6s is equal to count of 9s. The count of 3s is at least 1. For Example 12369, 383676989, 396 all
are 369 numbers whereas 213, 342143, 111 are not.
Given A and B find how many 369 numbers are there in the interval [A, B]
Input Format
line containing 2 integers A and B
Constraints
1<=A<=B<=10^5
Output Format
the number of 369 numbers between A and B inclusive
Sample Input 0
360 400

Sample Output 0
2

Explanation 0
only 369 and 396 follow the rule from 360 to 400. So, count would be 2
Test Input 1
121 4325

Test Output 1
60

Test Input 2
300 700

Test Output 2
4

Test Input 3
100 2000
Test Output 3
12

You might also like