#include <bits/stdc++.h>
using namespace std;
string s;
int res;
const int N = 200005;
int sum[N][26];
int n;
bool check(int l, int r) {
  int cnt1 = 0;
  for (int c = 0; c < 26; c++) cnt1 += (sum[r][c] - sum[l - 1][c]) % 2;
  return (cnt1 < 2);
}
map<pair<int, int>, int> mm;
int dp(int l, int r) {
  if (mm[make_pair(l, r)] != 0) return mm[make_pair(l, r)];
  if (check(l, r)) {
    mm[make_pair(l, r)] = 1;
    return 1;
  }
  int ans = r - l + 1;
  for (int i = l; i <= r; i++) {
    if (check(l, i)) {
      ans = min(ans, dp(l, i) + dp(i + 1, r));
      break;
    }
  }
  for (int i = r; i >= l; i--) {
    if (check(i, r)) {
      ans = min(ans, dp(l, i - 1) + dp(i, r));
      break;
    }
  }
  mm[make_pair(l, r)] = ans;
  return ans;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s;
  n = s.size();
  for (int c = 0; c < 26; c++)
    for (int i = 1; i <= n; i++)
      sum[i][c] = sum[i - 1][c] + (int(s[i - 1] - 'a') == c);
  cout << dp(1, n);
  return 0;
}
