#include <bits/stdc++.h>
using namespace std;
char s[(int)(2 * 1e5 + 5)];
int n, dp[(int)(2 * 1e5 + 5)];
int dfs(int cur) {
  if (cur == n + 1) return 0;
  if (~dp[cur]) return dp[cur];
  int mark[300] = {0}, tek = 0, cift = 0;
  int re = INT_MAX;
  for (int i = cur; i <= n; i++) {
    if (mark[(int)s[i]] == 0) {
      mark[(int)s[i]]++;
      tek++;
    } else {
      if (mark[(int)s[i]] & 1)
        tek--, cift++;
      else
        tek++, cift--;
      mark[(int)s[i]]++;
    }
    if (tek < 2) re = min(re, dfs(i + 1) + 1);
  }
  return dp[cur] = re;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%s", s + 1);
  n = strlen(s + 1);
  printf("%d\n", dfs(1));
}
