#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const int INF = 2000000001;
const long long int INFll = 2e18;
const double Micro = 1e-5;
int UnUsedVariable() {
  if (INF || Micro || MOD || INFll || MOD2) {
    ;
  }
  return 0;
}
inline int isEven(int x) { return x % 2 == 0; }
inline int isOdd(int x) { return x % 2 == 1; }
inline long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
inline long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
int EintN(long long int array[], const int num) {
  for (int i = 0; i < num; i++) {
    cerr << array[i] << " ";
  }
  printf("\n");
  ;
  return 0;
}
int EintNN(const int heighth, const int width, int array[heighth][width]) {
  for (int i = (0); i < (heighth); i++) {
    for (int k = (0); k < (width); k++) {
      { cerr << array[i][k] << " "; }
    }
    printf("\n");
    ;
  }
  printf("\n");
  ;
  return 0;
}
int Eint(string str, const long long int num) {
  cerr << str << " is " << num << " now." << endl;
  return 0;
}
inline long long int maxll(long long int A, long long int B) {
  return A > B ? A : B;
}
string S;
long long int Sl = 0;
long long int Aaplay(string S5, long long int Sl, long long int read,
                     long long int num, string before) {
  if (read == Sl) return num;
  if (read == Sl - 1) {
    if (S5.substr(read, 1) != before)
      return num + 1;
    else
      return -1;
  }
  if (num > (Sl * 2 / 3) + 2) return -MOD;
  if (before.length() == 2)
    return Aaplay(S5, Sl, read + 1, num + 1, S5.substr(read, 1));
  if (S5.substr(read, 1) != before) {
    if (read != 0 and
        ((S5[read - 1]) != (S5[read]) and (S5[read]) != (S5[read + 1]) and
         (S5[read + 1]) != (S5[read - 1])))
      return Aaplay(S5, Sl, read + 1, num + 1, S5.substr(read, 1));
    else
      return max(Aaplay(S5, Sl, read + 1, num + 1, S5.substr(read, 1)),
                 Aaplay(S5, Sl, read + 2, num + 1, S5.substr(read, 2)));
  } else
    return Aaplay(S5, Sl, read + 2, num + 1, S5.substr(read, 2));
  return -MOD;
}
long long int Acheck(string S2) {
  if (S2.length() == 1) return 1;
  if (S2.length() == 2) {
    if (S2[0] == S2[1]) {
      return 1;
    } else {
      return 2;
    }
  }
  return Aaplay(S2, S2.length(), 0, 0, "0");
}
long long int doA(string S3) {
  long long int ans = 0;
  long long int read = 0;
  for (int i = (1); i < (S3.length() - 2); i++) {
    if (((S3[i - 1]) != (S[i]) and (S[i]) != (S[i + 1]) and
         (S[i + 1]) != (S3[i - 1]))) {
      ans += Acheck(S3.substr(read, i - read));
      read = i;
    }
  }
  ans += Acheck(S3.substr(read, S3.length() - read));
  return ans;
}
int Ap() {
  int ans;
  ans = 0;
  cin >> S;
  Sl = S.length();
  {
    cout << (doA(S)) << endl;
    return 0;
  };
  return 0;
}
long long int Bp() {
  long long int ans;
  ans = 0;
  return 0;
}
int Cp() {
  int ans;
  ans = 0;
  return 0;
}
int Dp() {
  long long int N = 0;
  {
    cout << (N) << endl;
    return 0;
  };
  return 0;
}
signed main() {
  Ap();
  return 0;
}
