#include "bits/stdc++.h" #define rep(i,n) for(int i=0;i> N; int ans = 0; for (int i = N.size() - 1; i >= 0; i--) { if (N[i] == '0') continue; if (i == 0) { ans++; break; } if (N[i - 1] == '0') { ans++; continue; } ans++; while (N[i - 1] == '1' && i > 0) { i--; } if (i > 0) N[i - 1] = '1'; else ans++; } cout << ans << endl; }