#include <bits/stdc++.h>
using namespace std;

int mmin(int a, int b) {
  if(a == -1) return b;
  if(b == -1) return a;
  return min(a, b);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int i,j,k,w;
    string s;
    cin >> s;
    int N = s.length();
    int D = 10;
    int bins = count(begin(s),end(s),'0') + count(begin(s),end(s),'1');
    if(bins==N){
        D=2;
    }
    int DB = (1<<D);

    int dp[N + 5][DB][D];
    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 0;

    int ans = INT_MAX;
    for(i=0;i<N;++i) {
    int curr = s[i] - '0';
    for(j=0;j<DB;++j) {
        for(k=0;k<D;++k){
            if(dp[i][j][k] == -1) continue;
            for(w=0;w<D;++w){
                int bit = 1 << w;
                if(w == curr && (!(j & bit) || (k == w))) {
                    dp[i + 1][j | (1 << w)][w] = mmin(dp[i + 1][j | (1 << w)][w], dp[i][j][k]);
                    if(i + 1 == N) ans = min(ans, dp[i][j][k]);
                }
                else if(w != curr && (!(j & bit) || (k == w))) {
                    dp[i + 1][j | (1 << w)][w] = mmin(dp[i + 1][j | (1 << w)][w], dp[i][j][k] + 1);
                    if(i + 1 == N) ans = min(ans, dp[i][j][k] + 1);
                }
            }
        }
    }
    }

    cout << ans << '\n';
}