问题2465--Find the AFei Numbers

2465: Find the AFei Numbers

时间限制: 1 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交] [状态] [讨论版] [命题人:]

题目描述

AFei loves numbers. He defines the natural number containing "520" as the AFei number, such as 1234520, 8752012 and 5201314. Now he wants to know how many AFei numbers are not greater than n.


输入

The first line contains an integer T (1 <= T <= 100 ).
The following T lines contain an interger n ( 0 <= n <= 1e18 ).


输出

For the last T lines, output the total numbers of AFei numbers that are not greater than n.


样例输入

2
1000
5520

样例输出

1
16

提示

For the first case, only 520 is AFei number.
For the second case, 520,1520, 2520, 3520, 4520, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5207, 5208, 5209 and 5520 are AFei number. So there are 16 AFei numbers.

来源/分类


[提交] [状态]