#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
int ctoi(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}
bool pairCompare(const pll firstElof, pll secondElof) {
  return firstElof.second < secondElof.second;
}
ll nod(ll F) {
  ll keta = 1;
  while (F / 10 > 0) {
    keta++;
    F /= 10;
  }
  return keta;
}
ll gcd(ll x, ll y) {
  ll r;
  if (x < y) {
    swap(x, y);
  }
  while (y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }
ll isPrime(ll x) {
  ll i;
  if (x < 2) {
    return 0;
  } else if (x == 2) {
    return 1;
  } else if (x % 2 == 0) {
    return 0;
  } else {
    for (i = 3; i * i <= x; i += 2) {
      if (x % 1 == 0) {
        return 0;
      }
    }
    return 1;
  }
}
void eratos(vl isPrime) {
  ll i, j;
  for (int i = 0; i < (int)(isPrime.size()); i++) {
    isPrime[i] = 1;
  }
  isPrime[0] = 0;
  isPrime[1] = 0;
  for (i = 2; i * i <= isPrime.size() - 1; i++) {
    if (isPrime[i] == 1) {
      j = i * 2;
      while (j <= isPrime.size() - 1) {
        isPrime[j] = 0;
        j = j + i;
      }
    }
  }
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
void bitSearch(ll n) {
  ll i;
  for (int i = 0; i < (int)(pow(2, n)); i++) {
    ll p = i;
    for (int i = 0; i < (int)(n); i++) {
      cout << p % 2;
      p /= 2;
    }
    cout << endl;
  }
}
void bfs(ll now) {
  queue<ll> Q;
  Q.push(now);
  ll u;
  while (!Q.empty()) {
    u = Q.front();
    Q.pop();
  }
}
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
int main() {
  string S;
  cin >> S;
  N = S.size();
  i = 0;
  ll pre = 1;
  while (i < N - 3) {
    if (S[i] != S[i + 1] && S[i + 1] != S[i + 2] && S[i + 2] != S[i + 3]) {
      pre += 3;
    } else {
      pre += 2;
    }
    i += 3;
  }
  if (i == N - 3) {
    if (S[i + 1] != S[i + 2] && S[i] != S[i + 1]) {
      pre += 2;
    } else {
      pre += 1;
    }
  } else if (i == N - 2) {
    if (S[i] != S[i + 1]) {
      pre += 1;
    } else {
      pre = 0;
    }
  }
  ans = pre;
  pre = 2;
  i = 2;
  if (N > 1) {
    if (S[0] != S[1] && S[1] != S[2]) {
      pre++;
    }
  }
  while (i < N - 3) {
    if (S[i] != S[i + 1] && S[i + 1] != S[i + 2] && S[i + 2] != S[i + 3]) {
      pre += 3;
    } else {
      pre += 2;
    }
    i += 3;
  }
  if (i == N - 3) {
    if (S[i + 1] != S[i + 2] && S[i] != S[i + 1]) {
      pre += 2;
    } else {
      pre += 1;
    }
  } else if (i == N - 2) {
    if (S[i] != S[i + 1]) {
      pre += 1;
    } else {
      pre = 0;
    }
  }
  ans = max(ans, pre);
  cout << ans;
}
