#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  string t;
  bool notend = true;
  int cnt = 0;
  while (notend) {
    notend = false;
    bool rem = false;
    for (int i = 0; i < s.size(); i++) {
      if (i == s.size() - 1) {
        if (!rem && i != 0) t.push_back(s.at(i));
      } else if (rem) {
        rem = false;
        continue;
      } else if (s.at(i) != s.at(i + 1)) {
        rem = true;
        cnt++;
        cnt++;
        notend = true;
      } else if (s.at(i) == s.at(i + 1)) {
        t.push_back(s.at(i));
      }
    }
    s = t;
    t = "";
  }
  int ans = cnt;
  cout << ans;
  cout << endl;
}
