#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, i, j, k, movedmemory, ans = 0;
  char down1, up1, up2;
  string s;
  cin >> s;
  n = s.length();
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  do {
    movedmemory = 0;
    for (i = 1; i < n - 2; i++) {
      up1 = s[i + 1];
      up2 = s[i + 2];
      down1 = s[i - 1];
      if (s[i] != up1) {
        if (down1 != up2) {
          movedmemory++;
          ans += 2;
          s.erase(i, 2);
          n -= 2;
          break;
        }
      }
    }
  } while (movedmemory > 0);
  do {
    movedmemory = 0;
    for (i = 0; i < n - 1; i++) {
      up1 = s[i + 1];
      if (s[i] != up1) {
        movedmemory++;
        ans += 2;
        s.erase(i, 2);
        n -= 2;
        break;
      }
    }
  } while (movedmemory > 0);
  std::cout << ans << std::endl;
  return 0;
}
