#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char a[100000];
  bool b[100001][26];
  vector<int> c[30];
  int sum[100000];
  int dp[100000];
  for (int i = 0; i < (int)100000; i++) {
    a[i] = 0;
    for (int j = 0; j < (int)26; j++) b[i][j] = 0;
    sum[i] = 0;
  }
  int k, s;
  int n, m;
  int x, y, z;
  int ans = 0;
  scanf("%s", a);
  n = strlen(a);
  c[0].push_back(0);
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)26; j++) {
      b[i + 1][j] = b[i][j];
    }
    if (b[i + 1][a[i] - 97] == 0) {
      sum[i + 1] = sum[i] + 1;
      b[i + 1][a[i] - 97] = 1;
    } else {
      sum[i + 1] = sum[i] - 1;
      b[i + 1][a[i] - 97] = 1;
    }
    c[sum[i + 1]].push_back(i + 1);
  }
  dp[0] = 1;
  for (int i = 1; i < n; i++) {
    x = dp[i - 1] + 1;
    if (sum[i + 1] > 0) {
      for (int j = 0; j < c[sum[i + 1] - 1].size() && c[sum[i + 1] - 1][j] < i;
           j++) {
        y = 0;
        for (k = 0; k < 26; k++) {
          if (b[c[sum[i + 1] - 1][j]][k] != b[i][k]) y++;
        }
        if (y <= 1) dp[i] = min(x, dp[c[sum[i + 1] - 1][j] - 1]);
      }
    }
    for (int j = 0; j < c[sum[i + 1]].size() && c[sum[i + 1]][j] < i; j++) {
      y = 0;
      for (k = 0; k < 26; k++) {
        if (b[c[sum[i + 1]][j]][k] != b[i][k]) y++;
      }
      if (y <= 1) dp[i] = min(x, dp[c[sum[i + 1]][j] - 1]);
    }
    if (sum[i + 1] > 0) {
      for (int j = 0; j < c[sum[i + 1] + 1].size() && c[sum[i + 1] + 1][j] < i;
           j++) {
        y = 0;
        for (k = 0; k < 26; k++) {
          if (b[c[sum[i + 1] + 1][j]][k] != b[i][k]) y++;
        }
        if (y <= 1) dp[i] = min(x, dp[c[sum[i + 1] + 1][j] - 1]);
      }
    }
  }
  printf("%d\n", dp[n - 1]);
  return 0;
}
