#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, z, x[100] = {"a", "b"};
  cin >> s;
  int ans = 0;
  if (s.length() == 1) {
    cout << 0;
    return 0;
  }
  for (int j = 1; x[j] != x[j - 1]; j++) {
    z = "";
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == s[i + 1] && s[i + 1] != s[i - 1])
        ans += 2;
      else if (s[i] != s[i - 1])
        z += s[i];
    }
    x[j] = z;
    s = z;
  }
  cout << ans;
  return 0;
}
