#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
bool endcheck(string &s) {
  bool f = false;
  for (int i = 0; i < (s.size() - 1); i++) {
    if (s[i] != s[i + 1]) {
      f = true;
      break;
    }
  }
  return f;
}
int main() {
  string s;
  cin >> s;
  int count = 0;
  while (s.size() > 1 && endcheck(s)) {
    string t;
    swap(t, s);
    int i = 1;
    while (i < t.size() && endcheck(t)) {
      if (t[i - 1] != t[i]) {
        i += 2;
        ++count;
      } else {
        i += 1;
        s.push_back(t[i - 1]);
      }
    }
    s.push_back(t[t.size() - 1]);
  }
  cout << (count * 2) << endl;
}
