题目链接:https://codeforces.com/contest/1675/problem/C

Polycarp bought a new expensive painting and decided to show it to his n friends. He hung it in his room. n of his friends entered and exited there one by one. At one moment there was no more than one person in the room. In other words, the first friend entered and left first, then the second, and so on.

It is known that at the beginning (before visiting friends) a picture hung in the room. At the end (after the n-th friend) it turned out that it disappeared. At what exact moment it disappeared — there is no information.

Polycarp asked his friends one by one. He asked each one if there was a picture when he entered the room. Each friend answered one of three:

  • no (response encoded with 0);
  • yes (response encoded as 1);
  • can't remember (response is encoded with ?).

Everyone except the thief either doesn't remember or told the truth. The thief can say anything (any of the three options).

Polycarp cannot understand who the thief is. He asks you to find out the number of those who can be considered a thief according to the answers.


Input

The first number t (1t104) — the number of test cases in the test.

The following is a description of test cases.

The first line of each test case contains one string s (length does not exceed 2105) — a description of the friends' answers, where si indicates the answer of the i-th friend. Each character in the string is either 0 or 1 or ?.

The given regularity is described in the actual situation. In particular, on the basis of answers, at least one friend can be suspected of stealing a painting.

It is guaranteed that the sum of string lengths over the entire input data set does not exceed 2105.


样例输入

8
0
1
1110000
?????
1?1??0?0
0?0???
??11
??0??

样例输出

1
1
2
5
4
1
1
3


Note

In the first case, the answer is 1 since we had exactly 1 friend.

The second case is similar to the first.

In the third case, the suspects are the third and fourth friends (we count from one). It can be shown that no one else could be the thief.

In the fourth case, we know absolutely nothing, so we suspect everyone.

大意and思路:

输入t组数据,每组一个字符串,含有  0 1 ?  ,表示是否看见赃物。其中好人只会 说实话和不知道,  坏人可以说任意。
根据这段字符串来确定  可疑的人员数量

特判断全?和长度  1 
找到第一个0,然后往回推到第一个1,这个1 到 0的距离 +1  就是可能的小偷数量