Lucky number Masha#1291

Lucky number Masha

1 sekunda
64 megabajtov
Težko

- Listen, Misha, they told us at school that there is a city somewhere in the world called Lviv, and there, young and handsome people claim that the lucky digits are 4 and 7 .

- So what?...

- So, Misha, I came up with my own lucky number — 47 . And I will be happy every time, in any number up to the given one, when these two digits appear together, forming my lucky number!

- Well, Mashenka, then you will be less happy than those boys from Lviv and much less often.

- Well, but I'm a girl!!!

Vhod

The first line contains a natural number (0 \le T \le 10^4) — the number of test cases. Each of the next lines contains a natural number not exceeding 2^{63} - 1.

Izhod

For each test case, print on a separate line the number of occurrences, among all natural numbers up to and including the given one, of Masha's lucky number as a contiguous digit subsequence.

Primeri

Primer 1

Loading
Loading