#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using vll = vector<long long>;
using Graph = vii;
const long long MOD = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int n2 = n;
  bool flag = true;
  int ans = 0;
  while (flag) {
    flag = false;
    string t = "";
    for (int i = 0; i < n - 1; i++) {
      if (s[i] != s[i + 1]) {
        ans++;
        i++;
        if (i == n - 2 && s[i] == s[i + 1]) t += s[i];
        flag = true;
      } else {
        t += s[i];
        if (i == n - 2) {
          t += s[i + 1];
        } else
          flag = true;
      }
    }
    s = t;
    n = s.size();
  }
  ans = ans * 2;
  cout << ans << endl;
}
