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