#include <bits/stdc++.h>
using namespace std;
string S;
set<long long> removed;
long long getnext(long long start) {
  for (long long i = start + 1; i < S.size(); i++) {
    if (removed.find(i) == removed.end()) {
      return i;
    }
  }
  return -1;
}
long long getprev(long long start) {
  for (long long i = start - 1; i >= 0; i--) {
    if (removed.find(i) == removed.end()) {
      return i;
    }
  }
  return -1;
}
int main() {
  cin >> S;
  for (long long i = 0; i < S.size(); i++) {
    long long start = i;
    if (removed.find(start) != removed.end()) {
      continue;
    }
    long long goal = getnext(start);
    if (goal == -1) {
      continue;
    }
    while (S[start] != S[goal]) {
      removed.insert(start);
      removed.insert(goal);
      start = getprev(start);
      goal = getnext(goal);
      if (start == -1 || goal == -1) {
        break;
      }
    }
  }
  cout << removed.size() << endl;
}
