t = int(input())
for _ in range(t):
s = input()
count = 0
for x in s:
if x == '?':
count+=1
elif x == '0':
count+=1
break
elif x == '1':
count = 1
print(count)
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define vi vector<lli>
#define pi pair<int,int>
#define all(a) a.begin(),a.end()
#define mem(h,x) memset(h,x,sizeof(h))
#define intmx 1000000007
using namespace std;
void solve()
{
//CROSS CHECK CORNER CASES(N==1)
string a;
cin >> a;
int ans = 0, n = a.size(), l = 0, r = n - 1;
for (int i = 0; i < n; i++)
{
if (a[i] == '1')
l = i;
}
for (int i = n - 1; i >= 0; i--)
{
if (a[i] == '0')
r = i;
}
cout << r - l + 1 << '\n';
}
int main()
{
// auto start=chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(false);
int t = 1;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cin >> t;
while (t--)
solve();
// auto stop=chrono::high_resolution_clock::now();
// auto durn=chrono::duration_cast<chrono::microseconds>(stop-start);
// cerr<<"\n"<<durn.count()/1000.0<<" ms\n";
}
1006A - Adjacent Replacements | 1195C - Basketball Exercise |
1206A - Choose Two Numbers | 1438B - Valerii Against Everyone |
822A - I'm bored with life | 9A - Die Roll |
1430B - Barrels | 279B - Books |
1374B - Multiply by 2 divide by 6 | 1093B - Letters Rearranging |
1213C - Book Reading | 1468C - Berpizza |
1546B - AquaMoon and Stolen String | 1353C - Board Moves |
902A - Visiting a Friend | 299B - Ksusha the Squirrel |
1647D - Madoka and the Best School in Russia | 1208A - XORinacci |
1539B - Love Song | 22B - Bargaining Table |
1490B - Balanced Remainders | 264A - Escape from Stones |
1506A - Strange Table | 456A - Laptops |
855B - Marvolo Gaunt's Ring | 1454A - Special Permutation |
1359A - Berland Poker | 459A - Pashmak and Garden |
1327B - Princesses and Princes | 1450F - The Struggling Contestant |