#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  string str;
  cin >> str;
  vector<int> dp(str.length());
  vector<set<int>> s(str.length());
  for (int i = (0); i < (str.length()); ++i) {
    set<char> odd;
    odd.insert(str[i]);
    for (int k = (i + 1); k < (str.length()); ++k) {
      if (odd.count(str[k]) == 1) {
        odd.erase(str[k]);
      } else {
        odd.insert(str[k]);
      }
      if (odd.size() <= 1) {
        s[k].insert(i);
      }
    }
  }
  dp[0] = 1;
  for (int i = (1); i < (str.length()); ++i) {
    int minimum = 10000000;
    for (auto it = s[i].begin(); it != s[i].end(); it++) {
      if (*it == 0)
        minimum = 1;
      else
        minimum = min(minimum, dp[*it - 1] + 1);
    }
    dp[i] = min(dp[i - 1] + 1, minimum);
  }
  cout << dp[str.length() - 1] << endl;
}
