#include <bits/stdc++.h>
int main() {
  char a[2000000];
  bool now[26];
  int l = 0, r, temp = 0, ans = 1, left, right = 0;
  for (int i = 0; i < 26; i++) now[i] = false;
  for (int i = 0; i < 2000000; i++) a[i] = '\0';
  scanf("%s", a);
  for (r = 0; a[r] != '\0'; r++) {
    if (now[a[r] - 97]) {
      now[a[r] - 97] = false;
      temp--;
    } else {
      now[a[r] - 97] = true;
      temp++;
    }
    if (temp < 2) left = r + 1;
  }
  if (left == r) {
    printf("1\n");
    return 0;
  }
  while (l != r) {
    for (int i = 0; i < 26; i++) now[i] = false;
    temp = 0;
    if (right == 0) {
      for (int i = r - 1; i >= l; i--) {
        if (now[a[i] - 97]) {
          now[a[i] - 97] = false;
          temp--;
        } else {
          now[a[i] - 97] = true;
          temp++;
        }
        if (temp < 2) right = r - i;
      }
    }
    for (int i = 0; i < 26; i++) now[i] = false;
    temp = 0;
    if (left == 0) {
      for (int i = l; i < r; i++) {
        if (now[a[i] - 97]) {
          now[a[i] - 97] = false;
          temp--;
        } else {
          now[a[i] - 97] = true;
          temp++;
        }
        if (temp < 2) left = i - l + 1;
      }
    }
    if (left == r - l) {
      printf("%d\n", ans);
      return 0;
    }
    if (left > right) {
      l += left;
      left = 0;
      if (right == r - l) {
        printf("%d\n", ans + 1);
        return 0;
      }
      if (r - l < right) right = 0;
    } else {
      r -= right;
      right = 0;
      if (left == r - l) {
        printf("%d\n", ans + 1);
        return 0;
      }
      if (r - l < left) left = 0;
    }
    ans++;
  }
  printf("%d\n", ans);
}
