#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans = 0;
  int frag = 1;
  int now = 0;
  while(frag) {
    frag = 0;
    if(S.size() == 0 || S.size() == 1) {
      break;
    }
    for(int i = now; i < S.size() - 1; i++) {
      if(S[i] != S[i + 1]) {
        S.erase(S.begin() + i);
        S.erase(S.begin() + i);
        ans++;
        frag = true;
        // cout << "S: " << S << " ans: " << ans << " now: " << now << " i: " << i
             << endl;
        if(i == 0) {
          now = 0;
          break;
        } else {
          now = i - 1;
          break;
        }
      }
      if(S.size() == 0 || S.size() == 1) {
        break;
      }
    }
  }
  cout << ans * 2 << endl;
  return 0;
}