Rahul considers the numbers 3 and 5 to be lucky. All numbers containing only 3 and 5 are also considered lucky. Given a lucky number N, find the index of this number among all sorted lucky numbers. For this problem indexing starts from 1 instead of 0. So the first lucky number is 3, second lucky number is 5 and so on.
INPUT: The first line will contain an integer T denoting the number of test-cases. Each test case will contain a positive integer N as described in the problem statement.
OUTPUT: T lines containing the answer for each test case.
CONSTRAINTS: 1 <= T <= 1000 1 <= N <= 10000000000
If you consider the sorted list of all lucky numbers, 333 lies on the 7th position, therefore the answer is 7.