#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int main() {
  string s;
  cin >> s;
  for (int i = 1; i < s.size();) {
    if (i != 0 && s[i] != s[i - 1]) {
      ans++;
      s.erase(i - 1, 2);
      i--;
    } else
      i++;
  }
  cout << ans;
}
