#include <bits/stdc++.h>
using namespace std;
int ans = 0;
void calc(string s) {
  int n = (int)s.length(), prev = ans;
  vector<bool> bad(n, false);
  vector<int> next(n, -1);
  for (int i = 0; i < n - 1; i++) {
    if (((s[i] == '0' && s[i + 1] == '1') ||
         (s[i] == '1' && s[i + 1] == '0')) &&
        !bad[i] && !bad[i + 1]) {
      bad[i] = bad[i + 1] = true;
      ans += 2;
      int l = i - 1, r = i + 1;
      if (i - 1 >= 0) {
        next[i - 1] = r;
      }
      while (l >= 0 && r < n) {
        if (bad[l] != bad[r]) {
          break;
        }
        if (((s[l] == '0' && s[r] == '1') || (s[l] == '1' && s[r] == '0')) &&
            !bad[l] && !bad[r]) {
          bad[l] = bad[r] = true;
          if (l - 1 >= 0) {
            next[l - 1] = r + 1;
          }
          l--, r++;
          i = r - 1;
          ans += 2;
          continue;
        }
        break;
      }
    }
  }
  if (ans == prev) {
    return;
  }
  string ss = "";
  for (int i = 0; i < n; i++) {
    if (!bad[i]) {
      ss += s[i];
    }
    if (next[i] != -1) {
      i = next[i] - 1;
    }
  }
  calc(ss);
}
int main() {
  string s;
  cin >> s;
  calc(s);
  printf("%d\n", ans);
  return 0;
}
