#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool Max(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool Min(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T> >;
static const long long MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long ans = 0;
  bool found;
  string str;
  long i, len;
  while (1) {
    found = false;
    len = s.size() - 1;
    str = "";
    for ((i) = 0; (i) < (len); (i)++) {
      if (s[i] != s[i + 1]) {
        found = true;
        i++;
        ans += 2;
      } else {
        str += s[i];
      }
    }
    if (!found) break;
    s = str;
  }
  cout << (ans) << '\n';
  return 0;
}
