#include <bits/stdc++.h>
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
using namespace std;
using Graph = vector<vector<int64_t>>;
const double pi = M_PI;
const int64_t MOD = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  list<char> ss;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    ss.push_back(s[i]);
  }
  int64_t ans = 0, oans = -1;
  while (ans - oans != 0) {
    oans = ans;
    int sn = ss.size() - 1;
    int ind = 0;
    for (auto itr = ss.begin(); ind < sn;) {
      if (!(*itr == *next(itr))) {
        itr = ss.erase(itr);
        itr = ss.erase(itr);
        ans += 2;
        sn -= 2;
      } else {
        ++itr;
        ind++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
