// solution<1>
// Time 0.16 s
// memory 5.3 M
------------------------>>
#include<iostream>
#define ll long long
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
void solve()
{
string ans;
cin >> ans;
ll count = 0;
if (ans[0] == '0')
{
count++;
}
for (ll i = 1; i < ans.length(); i++)
{
if (ans[i] !=ans[i-1])
count++;
}
cout << count << "
";
}
int main()
{
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
-----------------------------------------------------------------------------------------
// solution<2>
// Time 0.17 s
// memory 5.2 M
------------------------>>
#include<iostream>
#define ll long long
#include<vector>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
void solve()
{
string ans;
cin >> ans;
ll count = 0;
if (ans[0] == '0')
{
count++;
}
for (ll i = 0; i < ans.length()-1; i++)
{
if (ans[i] !=ans[i+1])
count++;
}
cout << count << "
";
}
int main()
{
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}