#include <bits/stdc++.h>
using namespace std;
bitset<27> dp[1000000];
map<pair<int, int>, int> mp;
int dfs(int left, int right) {
  if (mp.find(make_pair(left, right)) != mp.end()) {
    return mp[make_pair(left, right)];
  }
  if ((dp[left] ^ dp[right]).count() == 0 || left == right) return 1;
  int mi = 100000000;
  int count = 0;
  int a = left, b = right;
  while (b - a >= 1) {
    bitset<27> tmp = dp[a] ^ dp[b];
    if (tmp.count() <= 1) {
      mi = min(mi, dfs(left, a) + dfs(b + 1, right) + 1);
    }
    if (count % 2 == 0) {
      a++;
    } else {
      b--;
    }
    count++;
  }
  a = left, b = right;
  while (b - a >= 1) {
    bitset<27> tmp = dp[a] ^ dp[b];
    if (tmp.count() <= 1) {
      mi = min(mi, dfs(left, a) + 1);
    }
    { a++; }
  }
  a = left, b = right;
  while (b - a >= 1) {
    bitset<27> tmp = dp[a] ^ dp[b];
    if (tmp.count() <= 1) {
      mi = min(mi, dfs(b + 1, right) + 1);
    }
    { b--; }
  }
  return mp[make_pair(left, right)] = mi;
}
int main() {
  string str;
  cin >> str;
  dp[1][str[0] - 'a'] = 1;
  for (int i = 1; i < str.size(); i++) {
    bitset<27> tmp(1 << (str[i] - 'a'));
    dp[i + 1] = dp[i] ^ tmp;
  }
  cout << dfs(0, str.size()) << endl;
  return 0;
}
