#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template <typename T>
void swap(T *t1, T *t2) {
  T *tmp = t1;
  t1 = t2;
  t2 = tmp;
}
Int tmpi = 0;
double tmpd = 0.0;
void printDebug(vector<char> s) {
  for (Int i = 0; i < s.size(); i++) {
    cout << s[i] << " ";
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char ss[100001];
  vector<char> s;
  cin >> ss;
  Int n = strlen(ss);
  for (Int i = 0; i < n; i++) {
    s.push_back(ss[i]);
  }
  Int l, r;
  Int sum = 0;
  char now = s[0];
  bool flg = true;
  Int i = 1;
  while (i < s.size()) {
    if (s[i] != now) {
      sum += 2;
      l = i - 2;
      r = i + 1;
      if (!(l < 0 || n <= r)) {
        while (s[l] != s[r]) {
          sum += 2;
          l--;
          r++;
          if (l < 0 || n <= r) {
            i = l + 1;
            break;
          }
        }
      }
      s.erase(s.begin() + l + 1, s.begin() + r);
      i = l + 1;
      now = s[i];
      i++;
    } else {
      now = s[i];
      i++;
    }
  }
  cout << sum << endl;
  return 0;
}
