#include <bits/stdc++.h>
using namespace std;
int solve(string s, int k) {
  int temp = 0;
  int len = s.length();
  if (len <= 1)
    return k;
  else {
    int remove = -1;
    for (int i = 0; i <= len - 2; i++) {
      if (s[i] != s[i + 1]) {
        remove = i;
        break;
      }
    }
    if (remove == -1) return k;
    string sub_s;
    if (remove == 0)
      sub_s = s.substr(2, len - 2);
    else if (remove == len - 2)
      sub_s = s.substr(0, len - 2);
    else
      sub_s = s.substr(0, remove) + s.substr(remove + 2, len - remove - 2);
    return solve(sub_s, k + 2);
  }
}
int main() {
  string s;
  cin >> s;
  cout << solve(s, 0) << endl;
}
