#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout.setf(ios_base::fixed, ios_base::floatfield);
  string s;
  cin >> s;
  deque<char> Q;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    Q.push_front(s[i]);
    while (Q.size() > 2 && Q[0] != Q[1]) {
      Q.pop_front();
      Q.pop_front();
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}
