#include <bits/stdc++.h>
using namespace std;
const long mod = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
int gcd(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}
int lcm(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);
}
int main() {
  string s;
  cin >> s;
  long n = s.size();
  long ans = 0;
  vector<char> s1;
  for (int i = 0; i < n; ++i) {
    s1.push_back(s[i]);
  }
  while (true) {
    vector<char> s2;
    for (int i = 0; i < s1.size() - 1; ++i) {
      if (s1[i] != s1[i + 1]) {
        ans += 2;
        i++;
        if (i == n - 2) s2.push_back(s[i + 1]);
      } else {
        s2.push_back(s[i]);
        if (i == n - 2) s2.push_back(s[i + 1]);
      }
    }
    for (auto v : s2) {
      cerr << v;
    }
    cerr << endl;
    if (s1.size() == s2.size() || s2.size() == 0) {
      break;
    } else {
      s1.clear();
      for (int i = 0; i < s2.size(); ++i) {
        s1.push_back(s2[i]);
      }
    }
  }
  cout << ans;
}
