#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  n = s.length();
  vector<bool> removed(n, false);
  int ans = 0;
  int i = 0;
  int j = 1;
  while (j < n) {
    if (s[i] != s[j]) {
      ans += 2;
      removed[i] = true;
      removed[j] = true;
      int tmp = i;
      for (int k = i - 1; 0 <= k; --k) {
        if (!removed[k]) {
          i = k;
          j++;
          break;
        }
      }
      if (tmp == i) {
        i = j + 1;
        j += 2;
      }
    } else {
      i = j;
      j++;
    }
  }
  cout << ans << '\n';
  return 0;
}
