#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

//vector< vector<int> > cs(28, vector<int> ((int)1e6, 0));
int cs[28][(int)1e6] = {0};
//vector< vector<int> > dp((int)1e5, vector<int> ((int)1e5, (int)1e7));
int dp[(int)1e6][(int)1e6] = {0};
//vector< vector<int> > dp((int)6, vector<int> ((int)6, (int)1e7));

bool iscir(int r, int l) {
    int c = 0;
    for (int i = 0; i < 28; i++) {
        if ((cs[i][l+1] - cs[i][r])%2 == 1) {
            c++;
        }
    }
    if (c > 1) {
        return false;
    } else {
        return true;
    }
}

int dps(int r, int l) {
    if (dp[r][l] != 0 ){
        return dp[r][l];
    }
    if (iscir(r, l)) {
        dp[r][l] = 1;
        return dp[r][l];
    }
    int ret = (int)1e7;
    for (int i = 0; i < l - r; i++) {
        int tmp = dps(r, r+i) + dps(r+i+1, l);
        if (tmp < ret) {
            ret = tmp;
        }
    }
    dp[r][l] = ret;
    return ret;
}

void solve(string s) {
    for (int i = 1; i < s.size()+1; i++) {
        for (int j = 0; j < 28; j++) {
            cs[j][i] = cs[j][i-1];
        }
        cs[s[i-1] - 'a'][i]++;
    }
    for (int i = 0; i < s.size(); i++) {
        dp[i][i] = 1;
    }
    int ret = dps(0, s.size()-1);
    std::cout << ret << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    string s;

    gettimeofday(&start,NULL);

    std::cin >> s;
    solve(s);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}
