#include <bits/stdc++.h>
using namespace std;
string c;
int ans = 100005, len, res[100005];
void dfs(int k, int d) {
  if (res[k] <= d) return;
  if (d >= ans) return;
  res[k] = d;
  set<int> squ;
  squ.clear();
  for (int i = k; i < len; i++) {
    if (squ.count(c[i] - 'a')) {
      squ.erase(c[i] - 'a');
    } else {
      squ.insert(c[i] - 'a');
    }
    if (squ.size() <= 1) {
      dfs(i + 1, d + 1);
    }
  }
  if (squ.size() <= 1) {
    if (d + 1 <= ans) ans = d + 1;
  }
}
int main() {
  memset(res, 0x3f, sizeof(res));
  cin >> c;
  len = c.size();
  dfs(0, 1);
  cout << ans - 1 << endl;
  return 0;
}
