#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main() {
  while (~scanf("%s", str)) {
    int len = strlen(str);
    int ans = 0;
    for (int i = 0; i < len; i++) {
      if (i + 1 < len && str[i] != str[i + 1])
        ans += 2, i++;
      else {
        int j = i, cnt1 = 0, cnt0 = 0;
        while (str[j] == str[i] && j < len) j++, cnt0++;
        while (str[j] != str[i] && j < len) j++, cnt1++;
        ans += 2 * min(cnt0, cnt1);
        i = i + max(2 * min(cnt0, cnt1) - 1, 1);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
