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