Update appNew update is available. Click here to update.

Count Special Numbers

Posted: 26 Feb, 2021
Difficulty: Hard

PROBLEM STATEMENT

Try Problem

A positive integer is called a Special Number if all the digits in its decimal representation lie between 1 to 5 (both inclusive). For example : 245, 312, etc. are some special numbers, whereas 340, 17, 0, etc. are some non-special numbers.

Given an integer 'N' . Your task is to find how many special numbers lie between 1 to N.

Input Format :

The first line of the input contains an integer, 'T,’ denoting the number of test cases.

The first and only line of each test case contains the integer 'N'.   

Output Format :

For each test case, print an integer denoting the total count of special numbers between 1 to N.

Print the output of each test case in a new line.

Note :

You do not need to print anything. It has already been taken care of. Just implement the given function.

Constraints :

1 <= T <= 10^4
1 <= N <= 10^9

Time Limit: 1 sec