#include <bits/stdc++.h>
using namespace std;
uint64_t MOD = 1000000007;
int main() {
  string S;
  cin >> S;
  uint64_t ans = 0;
  while (1) {
    int num = 0;
    for (int i = 0; i < S.size() - 1; i++) {
      if (S.at(i) != S.at(i + 1)) {
        num++;
        S.erase(i, 2);
        i--;
      }
    }
    ans += num * 2;
    if (num == 0 || S.size() == 0) break;
  }
  cout << ans << endl;
}
