#include <bits/stdc++.h>
using namespace std;
string s;
set<int> used;
int main(void) {
  cin >> s;
  int cnt = 0;
  int block = 0;
  bool is_found = false;
  for (int i = 0; i < s.length(); ++i) {
    if (!is_found) {
      block = 0;
    }
    if (is_found && ((i - 2 * block - 1) >= 0) && block > 0) {
      if (s[i - 2 * block - 1] != s[i]) {
        if ((used.count(i - 2 * block - 1) == 0) && (used.count(i) == 0)) {
          used.insert(i - 2 * block - 1);
          used.insert(i);
          cnt += 2;
        }
      }
      is_found = false;
    }
    if (i + 1 < s.length()) {
      if (s[i] != s[i + 1]) {
        if ((used.count(i) == 0) && (used.count(i + 1) == 0)) {
          used.insert(i);
          used.insert(i + 1);
          cnt += 2;
          i++;
          block++;
          is_found = true;
        }
      }
    }
  }
  cout << cnt << endl;
}
