#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll ans = 0;
  string s;
  cin >> s;
  deque<char> q;
  char last;
  q.push_back(s[0]);
  last = s[0];
  for (ll i = 1; i < s.length(); ++i) {
    if (last != s[i] && q.size() > 1) {
      ans += 2;
      q.pop_back();
      last = q.back();
    } else if (last != s[i]) {
      ans += 2;
      i++;
      last = s[i];
    } else {
      q.push_back(s[i]);
      last = s[i];
    }
  }
  cout << ans;
  return 0;
}
