#include <bits/stdc++.h>
using namespace std;
string a;
int n;
int dp[300009];
int ssss(int i) {
  if (i == n) return 0;
  if (dp[i] != -1) return dp[i];
  set<char> s;
  s.clear();
  int d = 5000000;
  for (int j = i; j < n; j++) {
    if (s.find(a[j]) != s.end())
      s.erase(a[j]);
    else
      s.insert(a[j]);
    if (s.size() <= 1) d = min(d, 1 + ssss(j + 1));
  }
  return dp[i] = d;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> a;
  n = a.size();
  cout << ssss(0);
}
