#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  int no_cubes = 0;
  bool stop = 0;
  cin >> s;
  int i = 0;
  int n = s.length();
  while (i < n - 1)
    if (s[i] != s[i + 1]) {
      no_cubes += 2;
      int left = i - 1;
      int right = i + 2;
      int no_del = 2;
      while (left >= 0 && right < n)
        if (s[left] != s[right]) {
          --left;
          ++right;
          no_cubes += 2;
          no_del += 2;
        } else
          break;
      ++left;
      right--;
      s = s.substr(0, left - 1) + s.substr(right, n - right - 1);
      n -= no_del;
    } else
      ++i;
  cout << no_cubes;
  return 0;
}
