// yukicoder 884 Eat and Add // 2019.9.21 bal4u #include #if 1 int getchar_unlocked(void); #define gc() getchar_unlocked() #else #define gc() getchar() #endif int ins(char *s) { // 文字列の入力 スペース以下の文字で入力終了 char *p = s--; int c; do c = gc(), *++s = c & 1; while (c > ' '); return s - p; } #define MIN(a,b) ((a)<=(b)?(a):(b)) char N[200005]; int w; int main() { int i, j, ans; w = ins(N+1); ans = 0, i = w; while (1) { while (i > 0 && N[i] == 0) i--; if (i == 0) break; j = i; while (N[i]) i--; j -= i; if (i == 0) { ans += MIN(2, j); break; } if (j == 1) ans++; else if (i > 1 && N[i-1] == 0 && j <= 2) ans += j; else ans++, N[i] = 1; } printf("%d\n", ans); return 0; }