#include <bits/stdc++.h>
using namespace std;
int n, ans;
const int N = 300010;
char a[N];
int main() {
  scanf("%s", a + 1);
  int len = strlen(a + 1);
  for (int i = 1; i <= len; i++) {
    if (a[i] == a[i - 1]) continue;
    int s = 0;
    for (int j = i; a[j] == a[i]; j++) s++;
    ans += s / 3 * 2;
    if (s % 3) ans++;
  }
  cout << ans;
}
