#include <bits/stdc++.h>
using namespace std;
bool is_palindrome(const string& s) {
  int size = s.size();
  int limit = size / 2;
  for (int i = 0; i < limit; i++) {
    if (s[i] != s[size - 1 - i]) {
      return false;
    }
  }
  return true;
}
int main(int argc, char const* argv[]) {
  ios::sync_with_stdio(false);
  string cubes;
  getline(cin, cubes);
  int count = 0;
  while (cubes.size() != 0 && !is_palindrome(cubes)) {
    for (int i = 0; i < cubes.size() - 1; i++) {
      if (!cubes.size())
        break;
      else if (cubes[i] != cubes[i + 1]) {
        count++;
        cubes.erase(i, 2);
      }
    }
  }
  cout << count * 2 << endl;
  return 0;
}
