#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
const double pi = acos(-1);
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> vec;
  for (long long i = 0; i < (n); i++) vec.push_back(s[i] - '0');
  int now = 0;
  int have = n;
  while (now <= have - 1 && 0 <= now) {
    if (vec[now] != vec[now + 1]) {
      vec.erase(vec.begin() + now);
      vec.erase(vec.begin() + now);
      have -= 2;
      if (now != 0) now--;
    } else {
      now++;
    }
  }
  cout << n - have << endl;
}
