#include <bits/stdc++.h>
std::vector<char> remove(std::vector<char> orig) {
  if (orig.size() == 0 || orig.size() == 1) {
    return orig;
  }
  std::vector<char> ans;
  for (size_t i = 0; i < orig.size() - 1; ++i) {
    if (orig.size() > i + 1 && orig.at(i) == orig.at(i + 1)) {
      ans.push_back(orig.at(i));
    } else {
      ++i;
    }
  }
  if (ans.size() > 0) {
    if (ans.at(ans.size() - 1) == orig.at(orig.size() - 1)) {
      ans.push_back(orig.at(orig.size() - 1));
    } else {
      ans.pop_back();
    }
  }
  return ans;
}
int main() {
  std::string s;
  std::cin >> s;
  std::vector<char> s_char_array;
  for (size_t i = 0; i < s.size(); ++i) {
    s_char_array.push_back(s[i]);
  }
  unsigned int length = s_char_array.size();
  while (true) {
    s_char_array = remove(s_char_array);
    const unsigned int new_length = s_char_array.size();
    if (new_length == 0 || new_length == length) {
      break;
    }
    length = new_length;
  }
  std::cout << s.size() - s_char_array.size() << std::endl;
  return 0;
}
