#include <bits/stdc++.h>
const int INF = 100000000;
const double EPS = 1e-10;
const int MOD = 1000000007;
using namespace std;
int main() {
  string s;
  cin >> s;
  char t[30][200010];
  set<string> st;
  map<string, int> table;
  for (int i = 0; i < 26; i++) t[i][0] = '0';
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (j == (int)s[i] - (int)'a') {
        if (t[j][i] == '0')
          t[j][i + 1] = '1';
        else
          t[j][i + 1] = '0';
      } else
        t[j][i + 1] = t[j][i];
    }
  }
  string u[200010] = {};
  for (int i = 0; i < s.size() + 1; i++)
    for (int j = 0; j < 26; j++) u[i] += t[j][i];
  int tmp = 0;
  for (int i = 0; i < s.size() + 1; i++) {
    if (st.find(u[i]) == st.end()) {
      st.insert(u[i]);
      table[u[i]] = tmp;
      tmp++;
    }
  }
  int e[400010];
  for (int i = 0; i < 2 * s.size() + 2; i++) e[i] = -1;
  for (int i = 0; i < s.size() + 1; i++) {
    if (e[2 * table[u[i]] + i % 2] == -1) e[2 * table[u[i]] + i % 2] = i;
  }
  int dp[200010] = {};
  string x, y;
  int k, l, ml, mr, mm;
  for (int i = 1; i <= s.size(); i++) {
    dp[i] = 500000;
    x = u[i];
    for (int j = 0; j < 26; j++) {
      y = x;
      if (y[j] == '0')
        y[j] = '1';
      else
        y[j] = '0';
      if (st.find(y) != st.end()) {
        k = 2 * table[y];
        if (i % 2 == 0) k++;
        ml = e[k];
        if (ml == -1 || ml >= i)
          continue;
        else
          dp[i] = min(dp[i], dp[ml] + 1);
      }
    }
  }
  if (u[s.size()] != u[0])
    cout << dp[s.size()] << endl;
  else
    cout << '1' << endl;
  return 0;
}
