#include <bits/stdc++.h>
using namespace std;
void flip(string& str, int n) {
  str[n] = '0';
  str[n + 1] = '1';
  str[n + 2] = '0';
}
map<char, int> chMp;
bool isPalim(string str) {
  for (char c = 'a'; c != 'z' + 1; ++c) {
    chMp[c] = 0;
  }
  for (auto s : str) {
    chMp[s]++;
  }
  int oddNum = 0;
  int evenNum = 0;
  for (char c = 'a'; c != 'z' + 1; ++c) {
    if (chMp[c] % 2 == 0) {
      evenNum++;
    } else {
      oddNum++;
    }
  }
  if (oddNum > 1)
    return false;
  else
    return true;
}
int dfs(string str) {
  if (str.size() == 0) return 0;
  int maxLen = 0;
  vector<string> next;
  for (int i = 0; i < str.size(); ++i) {
    if (isPalim(str.substr(i, str.size() - i))) {
      maxLen = max(maxLen, i);
      next.push_back(str.substr(0, i));
    }
    if (isPalim(str.substr(0, str.size() - i))) {
      maxLen = max(maxLen, i);
      next.push_back(str.substr(str.size() - i, str.size() - i));
    }
    if (next.size() > 0) break;
  }
  int maxCos = 0;
  for (auto n : next) {
    maxCos = max(maxCos, dfs(n));
  }
  return 1 + maxCos;
}
void pA() {
  string str;
  cin >> str;
  cout << dfs(str) << endl;
}
void pB() {
  int H, W;
  cin >> H >> W;
  vector<string> mp(H);
  for (auto& m : mp) cin >> m;
  int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
  int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (mp[i][j] == '.') {
        int cnt = 0;
        for (int k = 0; k < 8; ++k) {
          int ny = i + dy[k];
          int nx = j + dx[k];
          if (ny < 0 || ny >= H) continue;
          if (nx < 0 || nx >= W) continue;
          if (mp[i + dy[k]][j + dx[k]] == '#') cnt++;
        }
        mp[i][j] = '0' + cnt;
      }
    }
  }
  for (auto m : mp) cout << m << endl;
}
unsigned bit_count(unsigned n) {
  unsigned i = 0;
  while (n) {
    i += n & 1;
    n >>= 1;
  }
  return i;
}
int N, M;
set<int> path[100004];
long long addPath() {
  long long cnt = 0;
  for (int n0 = 1; n0 <= N; ++n0) {
    for (auto n1 : path[n0]) {
      if (n0 == n1) continue;
      for (auto n2 : path[n1]) {
        if (n1 == n2) continue;
        if (n0 == n2) continue;
        for (auto n3 : path[n2]) {
          if (n2 == n3) continue;
          if (n1 == n3) continue;
          if (n0 == n3) continue;
          if (path[n0].find(n3) == path[n0].end()) {
            cnt++;
            path[n0].insert(n3);
            path[n3].insert(n0);
          }
        }
      }
    }
  }
  return cnt;
}
void pC() {
  cin >> N >> M;
  for (int m = 0; m < M; ++m) {
    int a, b;
    cin >> a >> b;
    path[a].insert(b);
    path[b].insert(a);
  }
  cout << addPath() << endl;
}
void pD() {
  int N, K;
  cin >> N >> K;
  vector<pair<long long, long long> > pt1(N), pt2(N);
  for (int i = 0; i < N; ++i) {
    cin >> pt1[i].first >> pt1[i].second;
    pt2[i].first = pt1[i].second;
    pt2[i].second = pt1[i].first;
  }
  sort(pt1.begin(), pt1.end());
  sort(pt2.begin(), pt2.end());
  vector<int> pt12(N), pt21(N);
  for (int i = 0; i < N; ++i) {
    pair<long long, long long> p1 = pt1[i];
    for (int j = 0; j < N; ++j) {
      if (p1.first == pt2[j].second && p1.second == pt2[j].first) {
        pt12[i] = j;
        pt21[j] = i;
        break;
      }
    }
  }
  long long minimum = INT64_MAX;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      long long sq =
          abs(pt1[i].first - pt1[j].first) * abs(pt1[i].second - pt1[j].second);
      if (sq == 0) continue;
      long long p1 = i;
      long long p2 = pt12[i];
      long long p1n = j;
      long long p2n = pt12[j];
      long long num =
          max(max(p1n, p1) - min(p1n, p1), max(p2, p2n) - min(p2, p2n)) + 1;
      cerr << sq << " " << num << endl;
      if (num >= K) minimum = min(minimum, sq);
    }
  }
  cout << minimum << endl;
}
int main() {
  pA();
  return 0;
}
