#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
const int INF = 1e9;
int N;
vvl alnumf, alnumb;
bool isPalindrome(vl alnum) {
  int sum = 0;
  for (int i = 0; i < (26); ++i) sum += alnum[i] % 2;
  return sum <= 1;
}
vl getAlnum(int l, int r) {
  vl alnum(26, 0);
  for (int i = 0; i < (26); ++i) {
    alnum[i] +=
        (l < r ? alnumf[r][i] - alnumf[l][i] : alnumb[l][i] - alnumb[r][i]);
  }
  return alnum;
}
bool isPalindrome(int l, int r) { return isPalindrome(getAlnum(l, r)); }
int main() {
  string s;
  cin >> s;
  N = s.length();
  alnumf.assign(N + 1, vl(26, 0));
  alnumb.assign(N + 1, vl(26, 0));
  for (int i = 0; i < (N); ++i) {
    int cf = s[i] - 'a';
    int cb = s[N - i - 1] - 'a';
    alnumf[i + 1][cf]++;
    alnumb[i + 1][cb]++;
    for (int j = 0; j < (26); ++j) {
      alnumf[i + 1][j] += alnumf[i][j];
      alnumb[i + 1][j] += alnumb[i][j];
    }
  }
  vl dp(N + 1, INF);
  dp[0] = 0;
  for (int r = (1); r < (N + 1); ++r) {
    for (int l = 0; l < (r); ++l) {
      if (isPalindrome(l, r)) {
        dp[r] = min(dp[r], dp[l] + 1);
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}
