use proconio::{input, marker::Chars}; fn main() { input! { mut s: Chars, } s.reverse(); let mut stack = vec![]; let mut ans = 0; while let Some(ch) = s.pop() { stack.push(ch); if stack.len() < 3 { continue; } if &stack[stack.len() - 3..] == &['1', '1', '0'] { let a = stack.pop().unwrap(); let b = stack.pop().unwrap(); let c = stack.pop().unwrap(); s.push(c); s.push(b); s.push(a); ans += 1; } } println!("{}", ans); }