#include <bits/stdc++.h>
using namespace std;
string s;
int fr[26][202020];
vector<vector<int> > pos(256);
bool ckPalPermute(int l, int r) {
  if ((s).size() == l || (s).size() == r) return 1;
  vector<int> cur(26, 0);
  int odd = 0;
  for (int i = 0; i < 26; ++i) {
    cur[i] = fr[i][r];
    if (l > 0) cur[i] -= fr[i][l - 1];
    odd += cur[i] % 2;
  }
  if ((r - l + 1) % 2 == 0) {
    return odd == 0;
  } else {
    return odd == 1;
  }
}
bool solve(int l, int r, int &ans) {
  if (ckPalPermute(l, r)) {
    ans += 1;
    return 1;
  } else {
    int minc = 1000010000;
    for (int long long = l; long long <= r; ++long long) {
      for (int i = (pos[s[long long] - 'a']).size() - 1; i >= 0; --i) {
        int cp = pos[s[long long] - 'a'][i];
        if (cp > r) continue;
        if (cp < long long) break;
        if (ckPalPermute(l, cp)) {
          int cur = 0;
          if (cp == (s).size() - 1 || solve(cp + 1, r, cur)) {
            if (minc > 1 + cur) {
              minc = 1 + cur;
            }
          }
        }
      }
    }
    ans = minc;
    return minc != 1000010000;
  }
}
map<pair<int, int>, int> memo;
int solve2(int l, int r) {
  if (l == (s).size() || r == (s).size()) return 0;
  if (ckPalPermute(l, r)) {
    return 1;
  } else {
    if (memo.count({l, r})) return memo[{l, r}];
    int cur = 1000010000;
    for (int i = r; i >= l; --i) {
      if (ckPalPermute(l, i)) {
        cur = min(cur, 1 + solve2(i + 1, r));
      }
      if (cur != 1000010000) break;
    }
    memo[{l, r}] = cur;
    return cur;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  cin >> s;
  int n = (s).size();
  for (int i = 0; i < n; ++i) {
    ++fr[s[i] - 'a'][i];
    pos[s[i] - 'a'].push_back(i);
    for (int j = 0; j < (i > 0) * 26; ++j) {
      fr[j][i] += fr[j][i - 1];
    }
  }
  cout << solve2(0, n - 1);
  return 0;
}
