#include <bits/stdc++.h>
using namespace std;
int abs(int a) { return (a > 0) ? a : -a; }
int main() {
  string s;
  cin >> s;
  vector<int> vec;
  int tmp = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i == 0)
      tmp++;
    else {
      if (s[i] == s[i - 1]) {
        tmp++;
        if (i == s.size() - 1) {
          vec.push_back(tmp);
        }
      } else {
        vec.push_back(tmp);
        tmp = 1;
      }
    }
  }
  int era = 0;
  for (int i = 1; i < vec.size(); i++) {
    if (vec[i - 1] < vec[i]) {
      era += vec[i - 1] * 2;
      vec[i] -= vec[i - 1];
      vec.erase(vec.begin() + i - 1);
    } else {
      era += vec[i] * 2;
      vec[i - 1] -= vec[i];
      vec.erase(vec.begin() + i);
    }
    i--;
  }
  cout << era << endl;
  return 0;
}
