#include <bits/stdc++.h>
using namespace std;
list<pair<char, int> > li;
int main() {
  string s;
  cin >> s;
  int cnt = 1;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == s[i - 1])
      cnt++;
    else {
      li.push_back({s[i - 1], cnt});
      cnt = 1;
    }
  }
  li.push_back({s.back(), cnt});
  int ans = 0;
  while (li.size() > 1) {
    for (auto it = li.begin(); it != li.end(); it++)
      cout << (*it).first << "   ";
    cout << "\n";
    for (auto it = li.begin(); it != li.end(); it++)
      cout << (*it).second << "   ";
    cout << "\n";
    for (auto it = li.begin(); it != li.end(); it++) {
      (*it).second--;
      auto temp = it;
      temp++;
      if (it != li.begin() && temp != li.end()) (*it).second--;
    }
    for (auto it = li.begin(); it != li.end(); it++) {
      if ((*it).second <= 0) {
        auto jt = it;
        --jt;
        li.erase(it);
        it = jt;
      }
    }
    for (auto it = li.begin(); it != li.end(); it++) {
      auto jt = it;
      ++jt;
      if (jt != li.end()) {
        if ((*jt).first == (*it).first) {
          (*it).second += (*jt).second;
          li.erase(jt);
        }
      }
    }
    ans++;
  }
  cout << ans << "\n";
}
