#include <bits/stdc++.h>
using ull = unsigned long long;
using namespace std;
template <typename T>
inline void dump(const T& x) {
  cout << "[" << x << "]" << endl;
}
template <typename T>
inline void dump(const vector<T>& x) {
  for (const auto v : x) {
    cout << v << " ";
  }
  cout << endl;
}
template <typename T>
inline void sort_asc(vector<T>& x) {
  std::sort(x.begin(), x.end());
}
template <typename T>
inline void sort_desc(vector<T>& x) {
  std::sort(x.begin(), x.end(), greater<T>());
}
int main() {
  string s;
  cin >> s;
  vector<int> line;
  auto current = s[0];
  ull result = 0;
  ull one = 0;
  ull two = 0;
  bool switched = false;
  for (auto i = 0; i < s.size(); i++) {
    if (i == 0) continue;
    if (current == s[i]) {
      if (two > 0) {
        two++;
        continue;
      }
      one++;
      switched = false;
      continue;
    } else {
      if (two > 0) {
        result += (two * 2);
        one = two = 0;
        current = s[i];
        switched = false;
        continue;
      }
      current = s[i];
      switched = true;
      two++;
      continue;
    }
  }
  if (switched) {
    result += (two * 2);
  }
  cout << result << endl;
  return 0;
}
