#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
using namespace std;
/*ll digni(ll x,ll y)
{
    if(y==0)return 1;
    if(y%2==0)
    {
        ll res=digni(x,y/2);
        return (res*res)%mod;
    }
    return (digni(x,y-1)*x)%mod;
}*/

int n;
string s;
int MASK = 1 << 10;
ll dp[2][MASK + 5];
ll cnt[100005][10];

int zameni(int l,int r,int c)
{
    int duz = r - l + 1;
    int ima = cnt[r][c] - cnt[l][c];
    return duz - ima;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
    cin>>s;
    n = s.size();
    s = "1" + s;

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<10;j++)
        {
            cnt[i][j] = cnt[i - 1][j] + (s[i] - '0' == j);
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<MASK;j++)
        {
            dp[i][j] = n + 100;
            for(int l = 0; l < i; l++)
            {
                for(int t = 0; t < 10; t++)
                {
                    if(dp[l][j ^ (1<<t)] + zameni(l + 1, i, t) < dp[i][j])
                    {
                        dp[i][j] = dp[l][j ^ (1<<t)] + zameni(l + 1, i, t);
                    }
                }
            }
        }
    }

    for(int i)
    
 	return 0;
}