#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char bef;
  int ans = 1;
  bef = s[0];
  for (int i = 1; i < s.size(); i++) {
    if (bef == '0') {
      ans++;
      bef = '1';
    } else if (bef == s[i]) {
      bef = '0';
    } else {
      ans++;
      bef = s[i];
    }
  }
  if (bef == '0') ans = 0;
  int ansan = ans;
  ans = 2;
  bef = s[2];
  for (int i = 3; i < s.size(); i++) {
    if (bef == '0') {
      ans++;
      bef = '1';
    } else if (bef == s[i]) {
      bef = '0';
    } else {
      ans++;
      bef = s[i];
    }
  }
  cout << max(ans, ansan) << endl;
}
