#include <bits/stdc++.h>

#define INF 1000010
#define mp make_pair

using namespace std;

void tst2(int a[], int n) {

    int br0[n], br1[n];
    for(int i = 0; i < n; i++) {
        br0[i] = br0[i - 1];
        br1[i] = br1[i - 1];
        if(a[i] == 0)
            br0[i]++;
        else
            br1[i]++;
    }

    int ans = min(br1[n - 1], br0[n - 1]);
    for(int i = 0; i < n; i++) {
        // prvo 1
        ans = min(ans, br0[i] + br1[n - 1] - br1[i]);
        
        // prvo 0
        ans = min(ans, br1[i] + br0[n - 1] - br0[i]);
    }
    cout << ans << endl;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin >> s;
    int n = s.size();

    bool testcase2 = true;
    int a[n];
    for(int i = 0; i < n; i++) {
        a[i] = s[i] - '0';
        if(a[i] > 1)
            testcase2 = false;
    }

    if(testcase2) {
        tst2(a, n);
        return 0;
    }

    int ALL = (1 << 10) - 1;
    vector< vector< pair<int, int> > > dp(n, vector< pair<int, int> >(ALL + 1, mp(INF, -1)));
    dp[0][0].first = 1; dp[0][0].second = -1;
    dp[0][(1 << a[0])].first = 0; dp[0][(1 << a[0])].second = a[0];

    for(int i = 0; i < n - 1; i++) {
        for(int mask = 0; mask <= ALL; mask++) {
            if(mask & (1 << a[i + 1])) {
                if(dp[i][mask].second == a[i + 1]) {
                    if(dp[i + 1][mask].first > dp[i][mask].first)
                        dp[i + 1][mask] = dp[i][mask];
                }
            } else {
                if(dp[i + 1][mask].first > dp[i][mask].first + 1) {
                    dp[i + 1][mask].first = dp[i][mask].first + 1;
                    dp[i + 1][mask].second = dp[i][mask].second;
                }
                if(dp[i + 1][mask | (1 << a[i + 1])].first > dp[i][mask].first) {
                    dp[i + 1][mask | (1 << a[i + 1])].first = dp[i][mask].first;
                    dp[i + 1][mask | (1 << a[i + 1])].second = a[i + 1];
                }
            }
        }
    }

    int ans = INF;
    for(int mask = 0; mask <= ALL; mask++)
        ans = min(ans, dp[n - 1][mask].first);

    cout << ans << endl;
    return 0;
}