#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

//macros
typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;




#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-7
#define PI 3.1415926535897932384626

int main(){
    string str;
    cin >> str;
    vector<pair<int,char> > groups;
    int cnt = 1;
    char cur = str[0];
    for(int i=1;i<str.length();i++){
        if(str[i]==str[i-1]){
            cnt++;
        }else{
            groups.PB(MP(cnt,cur));
            cnt = 1;
            cur = str[i];
        }
    }
    groups.PB(MP(cnt,cur));
    if(SZ(groups)<=1){
        cout << 0 << endl; return 0;
    }
    int ops = 0;
    while(true){
        int minit = 10000000;
        REP(i,SZ(groups)){
            int vv = groups[i].first;
            if(i>0 && i<SZ(groups)-1){
                vv /=2;
                if(groups[i].first%2==1) vv++;
            }
            minit=min(minit,vv);
        }
        ops+=minit;
        vector<pair<int,char> > newvec;
        REP(i,SZ(groups)){
            int sub = 2;
            if(i==0 || i==SZ(groups)-1) sub = 1;
            int nv = groups[i].first-minit*sub;
            if(nv<=0){
                //destroyed
            }else{
                newvec.PB(MP(nv,groups[i].second));
            }
        }
        if(SZ(newvec)<=1){
            cout << ops << endl; return 0;
        }
        groups.clear();
        cnt = 1;
        cur = newvec[0].second;
        for(int j=1;j<SZ(newvec);j++){
            if(newvec[j].second==cur){
                cnt++;
            }else{
                groups.PB(MP(cnt,cur));
                cnt = 1;
                cur = newvec[j].second;
            }
        }
        groups.PB(MP(cnt,cur));

        if(SZ(groups)<=1){
            cout << ops << endl; return 0;
        }

        REP(i,SZ(groups)){
            cout << groups[i].first << " ";
        }
        cout << endl;
    }



}
