#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int i = 0;
  int cnt = 0;
  if (s.length() == 1) {
    cout << 0 << endl;
    return 0;
  }
  int cnt2 = 0;
  while (1) {
    i = 0;
    cnt2++;
    if (cnt2 == 100) break;
    while (1) {
      if (s[i] != s[i + 1]) {
        s.erase(i, 2);
        cnt += 2;
        if (s.length() <= 1) {
          cout << cnt << endl;
          return 0;
        }
      } else
        i++;
      if (i >= s.length() - 1) {
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
