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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    cin >> s;

    vector<int> count[26];
    rep(i,0,26) count[i].resize(s.size());
    ++count[s[0]-'a'][0];
    rep(i,1,s.size()){
        rep(j,0,26) count[j][i]=count[j][i-1];
        ++count[s[i]-'a'][i];
    }

    vector<int> memo(s.size()+1,inf);
    vector<bool> done(s.size()+1);

    function<int(int)> rec=[&](int l){
        int& res=memo[l];
        if(done[l]) return res;
        done[l]=true;

        if(l==s.size()) return res=0;

        for(int r=s.size()-1; r>=l; --r){
            int odd=0;
            rep(j,0,26) if((count[j][r]-(l?count[j][l#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    cin >> s;

    vector<int> count[26];
    rep(i,0,26) count[i].resize(s.size());
    ++count[s[0]-'a'][0];
    rep(i,1,s.size()){
        rep(j,0,26) count[j][i]=count[j][i-1];
        ++count[s[i]-'a'][i];
    }

    vector<int> memo(s.size()+1,inf);
    vector<bool> done(s.size()+1);

    function<int(int)> rec=[&](int l){
        int& res=memo[l];
        if(done[l]) return res;
        done[l]=true;

        if(l==s.size()) return res=0;

        for(int r=s.size()-1; r>=l; --r){
            int odd=0;
            rep(j,0,26) if((count[j][r]-(l?count[j][l-1]:0))%2){
                ++odd;
                if(odd>1) break;
            }
            if(odd<=1){
                res=min(res,rec(r+1)+1);
                if(res<=2) return res;
            }
        }
        return res;
    };

    cout << rec(0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}
-1]:0))%2){
                ++odd;
                if(odd>1) break;
            }
            if(odd<=1){
                res=min(res,rec(r+1)+1);
                if(res==2) return res;
            }
        }
        return res;
    };

    cout << rec(0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}
