#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long ans = 0;
  string s;
  vector<pair<char, long long>> q;
  cin >> s;
  q.push_back({s[0], 1});
  for (long long i = 1; i < s.size(); i++) {
    if (s[i - 1] != s[i])
      q.push_back({s[i], 1});
    else
      q.back().second++;
  }
  while (true) {
    if (q.size() < 2) break;
    if (q[0].second >= q[1].second) {
      ans += q[1].second * 2;
      q[0].second -= q[1].second;
      if (q.size() > 2) {
        q[0].second += q[2].second;
        q.erase(q.begin() + 1, q.begin() + 3);
      } else
        q.erase(q.begin() + 1);
    } else {
      ans += q[0].second * 2;
      q[1].second -= q[0].second;
      q.erase(q.begin());
    }
    for (long long i = 0; i < q.size(); i++) {
      for (long long j = 0; j < q[i].second; j++) {
        cout << q[i].first;
      }
    }
    cout << endl;
  }
  cout << ans << endl;
}
