#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int n = s.size(), ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    int j = i + 1, cnt = 0;
    while (s[j] != s[i] && j < n) {
      cnt++;
      j++;
    }
    ans += cnt / 2 * 2;
    if (cnt == 0) {
      j = i + 1;
      while (s[j] == s[i] && j < n) {
        cnt++;
        j++;
      }
      if (cnt != 0) {
        cnt++;
        i = j - 1;
      }
      ans += cnt / 2 * 2;
    } else {
      cnt = 0;
      while (s[j] == s[i]) {
        cnt++;
        j++;
      }
      if (cnt != 0) cnt++;
      ans += cnt / 2 * 2;
      i = j - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
