#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  long long len = S.size();
  string ss;
  while (true) {
    bool f = false;
    for (long long i = 0; i < (long long)S.size() - 1; i += 2) {
      if (S[i] == S[i + 1]) {
        ss += (S[i] + S[i + 1]);
      }
    }
    if (ss.size() != S.size()) {
      S = ss;
      ss.clear();
      continue;
    }
    for (long long i = 1; i < (long long)S.size() - 2; i += 2) {
      if (S[i] == S[i + 1]) {
        ss += (S[i] + S[i + 1]);
      }
    }
    if (ss.size() != S.size()) {
      S = ss;
      ss.clear();
      continue;
    }
    break;
  }
  cout << len - ss.size() << endl;
}
