#include <bits/stdc++.h>
using namespace std;
bool isDivided(vector<string> x) {
  for (int i = 0; i < x.size() - 1; i++) {
    if (x.at(i) == x.at(i + 1)) {
      return false;
    }
  }
  return true;
}
bool divStrings(string& s, int r) {
  int n;
  n = s.size() - 1;
  vector<bool> v;
  fill(v.end() - r, v.end(), true);
  do {
    int tmp = 0;
    vector<string> divs;
    for (int i = 0; i < n; ++i) {
      if (v[i]) {
        divs.push_back(s.substr(tmp, i + 1 - tmp));
        tmp = i + 1;
      }
    }
    divs.back() = divs.back() + s.substr(tmp);
    if (isDivided(divs)) {
      return true;
    }
  } while (next_permutation(v.begin(), v.end()));
  return false;
}
int main() {
  string s;
  cin >> s;
  for (int i = s.size(); i > 0; i--) {
    if (divStrings(s, i)) {
      cout << i;
      break;
    }
  }
  return 0;
}
