#include <bits/stdc++.h>
using namespace std;
string s;
map<int, map<int, int>> table;
int count(int head, int tail) {
  if (table.count(head) > 0 && table[head].count(tail) > 0)
    return table[head][tail];
  map<int, int> check;
  for (int i = head; i <= tail; i++) {
    check[s[i] - 'a']++;
  }
  int odd = 0;
  for (auto i : check) odd += i.second % 2;
  int len = (tail - head + 1) % 2;
  if ((len == 0 && odd == 0) || (len == 1 && odd == 1)) {
    table[head][tail] = 1;
    return 1;
  }
  int c = 1e9;
  for (int i = head; i < tail; i++) {
    c = min(c, count(head, i) + count(i + 1, tail));
  }
  table[head][tail] = c;
  return c;
}
int main() {
  cin >> s;
  cout << count(0, s.size() - 1) << endl;
  return 0;
}
