#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e9;
const long long mod = 998244353;
const long double eps = 1e-9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
string s;
vector<vector<int> > cnt;
map<pair<int, int>, int> m;
int solve(int s, int t) {
  if (m.find(make_pair(s, t)) != m.end()) return m[make_pair(s, t)];
  int l = t - s;
  if (l == 0) return 0;
  if (l == 1) return 1;
  int ret = inf;
  while (ret == inf) {
    for (int i = s; i <= t - l; i++) {
      int tmp = 0;
      for (int j = 0; j < 26; j++) {
        tmp += (cnt[i + l][j] - cnt[i][j]) % 2;
      }
      if (tmp < 2) {
        ret = min(ret, 1 + solve(s, i) + solve(i + l, t));
        break;
      }
    }
    l--;
  }
  return m[make_pair(s, t)] = ret;
}
int main() {
  cin >> s;
  int n = s.size();
  cnt = vector<vector<int> >(n + 1, vector<int>(26, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) cnt[i + 1][j] = cnt[i][j];
    cnt[i + 1][s[i] - 'a']++;
  }
  cout << solve(0, n) << endl;
  return 0;
}
