#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int N = 1e5 + 5; string s; int cache[N][4]; vector<char> v = {'0', '1', '0', '1'}; int dp(int idx, int cur) { if(cur == 4) return 0; if(idx >= s.size()) return 0; int &ans = cache[idx][cur]; if(ans != -1) return ans; ans = 0; if(s[idx] == v[cur]) ans = max(dp(idx, cur + 1), 1 + dp(idx + 1, cur)); else ans = max(dp(idx, cur + 1), dp(idx + 1, cur)); return ans; } int32_t main() { IOS; memset(cache, -1, sizeof(cache)); cin >> s; int ans = dp(0, 0); cout << ans; return 0; }