#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(i,a,b) for(int i=a; i<b;i++)
#define loop(x,b) for(int x=0;x<b;x++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define inf (1LL <<60)
using namespace std;
void precal(){
}
void solve() {
string str;
cin >> str;
int zero = count(str.begin(), str.end(), '0');
int one = count(str.begin(), str.end(), '1');
int size = str.length();
int i = 0;
loop(i, size) {
if (str[i] == '1')
zero--;
else
one--;
if (min(zero, one) < 0) {
cout << size - i << endl;
return; // Exit the function once the condition is met
}
}
cout << 0 << endl;
}
int main(){
fast_io;
precal();
int t; cin>>t;
for(int i=0;i<t;i++){
solve();
}
return 0;
}
1395A - Boboniu Likes to Color Balls | 1637C - Andrew and Stones |
1334B - Middle Class | 260C - Balls and Boxes |
1554A - Cherry | 11B - Jumping Jack |
716A - Crazy Computer | 644A - Parliament of Berland |
1657C - Bracket Sequence Deletion | 1657B - XY Sequence |
1009A - Game Shopping | 1657A - Integer Moves |
230B - T-primes | 630A - Again Twenty Five |
1234D - Distinct Characters Queries | 1183A - Nearest Interesting Number |
1009E - Intercity Travelling | 1637B - MEX and Array |
224A - Parallelepiped | 964A - Splits |
1615A - Closing The Gap | 4C - Registration System |
1321A - Contest for Robots | 1451A - Subtract or Divide |
1B - Spreadsheet | 1177A - Digits Sequence (Easy Edition) |
1579A - Casimir's String Solitaire | 287B - Pipeline |
510A - Fox And Snake | 1520B - Ordinary Numbers |