#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long cnt = 0;
  long long len = s.size();
  for (int j = 0; j < 10000; ++j) {
    long long tmp = cnt;
    for (int i = 0; i < len - 1; ++i) {
      if (s[i] != s[i + 1]) {
        s.erase(s.begin() + i, s.begin() + i + 2);
        cnt += 2;
        len = s.size();
      }
    }
    if (cnt == tmp) {
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}
