#include <bits/stdc++.h>
using namespace std;
void solve(string S) {
  string s1 = S;
  while (true) {
    string s2 = "";
    if (s1.length() == 0) break;
    for (int i = 0; i < s1.length() - 1; i++) {
      if (s1[i] != s1[i + 1]) {
        i++;
        if (i == s1.length() - 2) s2 += s1[i + 1];
      } else {
        s2 += s1[i];
        if (i == s1.length() - 2) s2 += s1[i + 1];
      }
    }
    if (s1 == s2) break;
    s1 = s2;
  }
  if (S.length() == 1)
    cout << 0 << "\n";
  else
    cout << S.length() - s1.length() << "\n";
}
int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}
