#CF2230B. B. Digit String

B. Digit String

B. Digit String

You are given a string ss consisting of digits from 11 to 44.

Let's say that the string is beautiful if it is impossible to select some of its elements and write them out (in the same order as they appear in the string) to form a number that is a multiple of 44. For example, the strings 31, 222, 213 are beautiful, while the strings 143, 3123, 1322 are not. The empty string is considered beautiful.

Your task is to calculate the minimum possible number of elements in the string ss that need to be removed in order to make it beautiful.

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The only line of each test case contains a string ss (1s31051 \le |s| \le 3 \cdot 10^5), consisting of digits from 11 to 44.

Additional constraint on the input: the sum of the lengths of ss over all test cases doesn't exceed 31053 \cdot 10^5.

For each test case, print a single integer — the minimum possible number of elements in the string ss that need to be removed in order to make it beautiful.

ExampleNoteIn the first example, you have to delete the whole string.

In the second example, the string is already beautiful.

In the third example, you can delete the 11-st, 33-rd, 44-th, and 66-th characters, and you will get the string 213.

Input

InputThe first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The only line of each test case contains a string ss (1s31051 \le |s| \le 3 \cdot 10^5), consisting of digits from 11 to 44.

Additional constraint on the input: the sum of the lengths of ss over all test cases doesn't exceed 31053 \cdot 10^5.

Output

OutputFor each test case, print a single integer — the minimum possible number of elements in the string ss that need to be removed in order to make it beautiful.

Samples

5
4
13
1322
222
31
1
0
2
0
0

Note

NoteIn the first example, you have to delete the whole string.

In the second example, the string is already beautiful.

In the third example, you can delete the 11-st, 33-rd, 44-th, and 66-th characters, and you will get the string 213.