#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
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];
  for (i64 i = i64(0), i_max_for_repmacro = i64(26); i < i_max_for_repmacro;
       ++i)
    count[i].resize(s.size());
  ++count[s[0] - 'a'][0];
  for (i64 i = i64(1), i_max_for_repmacro = i64(s.size());
       i < i_max_for_repmacro; ++i) {
    for (i64 j = i64(0), j_max_for_repmacro = i64(26); j < j_max_for_repmacro;
         ++j)
      count[j][i] = count[j][i - 1];
    ++count[s[i] - 'a'][i];
  }
  vector<unordered_map<int, int>> memo(s.size());
  function<int(int, int)> rec = [&](int l, int r) {
    if (memo[l].find(r) != memo[l].end()) return memo[l][r];
    int &res = memo[l][r];
    res = inf;
    if (l > r) return res = 0;
    {
      int odd = 0;
      for (i64 j = i64(0), j_max_for_repmacro = i64(26); j < j_max_for_repmacro;
           ++j)
        if ((count[j][r] - (l ? count[j][l - 1] : 0)) % 2) ++odd;
      if (odd <= 1) return res = 1;
    }
    vector<int> opt_i;
    int opt = inf;
    for (i64 i = i64(l), i_max_for_repmacro = i64(r); i < i_max_for_repmacro;
         ++i) {
      int left_odd = 0, right_odd = 0;
      for (i64 j = i64(0), j_max_for_repmacro = i64(26); j < j_max_for_repmacro;
           ++j) {
        if ((count[j][i] - (l ? count[j][l - 1] : 0)) % 2) ++left_odd;
        if ((count[j][r] - count[j][i]) % 2) ++right_odd;
        if (max(left_odd, right_odd) > opt) break;
      }
      if (max(left_odd, right_odd) < opt) {
        opt_i.clear();
        opt_i.push_back(i);
        opt = max(left_odd, right_odd);
      } else if (max(left_odd, right_odd) == opt)
        opt_i.push_back(i);
    }
    for (int i : opt_i) {
      res = min(res, rec(l, i) + rec(i + 1, r));
      if (res <= 2) return res;
    }
    return res;
  };
  cout << rec(0, s.size() - 1) << endl;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}
