#include <bits/stdc++.h>
using namespace std;
string s;
map<int, map<int, int>> table;
int table2[26][2 * 100000 + 1];
int count(int head, int tail) {
  if (table.count(head) > 0 && table[head].count(tail) > 0)
    return table[head][tail];
  int odd = 0;
  for (int i = 0; i < (int)(26); ++i) {
    odd += (table2[i][tail + 1] - table2[i][head]) % 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;
  memset(table2, 0, 26 * (2 * 100000 + 1));
  for (int i = 0; i < (int)(s.size()); ++i) {
    int ch = s[i] - 'a';
    for (int j = 0; j < (int)(26); ++j) {
      table2[j][i + 1] = table2[j][i] + (j == ch ? 1 : 0);
    }
  }
  cout << count(0, s.size() - 1) << endl;
  return 0;
}
