#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans;
  string s;
  cin >> s;
  int i = 0;
  int n = 0;
  while (s.at(i) != NULL) {
    if (s.at(i) == s.at(i + 1)) {
      n++;
    }
    i++;
  }
  ans = (2 * n + 1) / 3;
  cout << ans << endl;
}
