#include using namespace std; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>s; int N=s.size(); reverse(s.begin(),s.end()); vector dp(2,INF); dp[0]=0; for(int i=0;i ndp(2,INF); int d=s[i]-'0'; for(int j=0;j<2;j++){ if(d+j==0){ chmin(ndp[0],dp[j]); }else if(d+j==1){ chmin(ndp[0],dp[j]+1); chmin(ndp[1],dp[j]+1); }else{ chmin(ndp[1],dp[j]); } } swap(dp,ndp); } cout<