use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let _n: usize = it.next().unwrap().parse().unwrap(); let s = it.next().unwrap(); let mut c1 = 0; let mut c9 = 0; let mut ans = 0; for c in s.chars() { match c { '1' => { if c9 >= 2 { ans += 1; c9 -= 2; } else { c1 += 1; } }, '9' => { if c1 >= 1 { ans += 1; c1 -= 1; } else { c9 += 1; } }, _ => ans += 1, } } while c1 >= 2 { ans += 1; c1 -= 1; } println!("{}", ans); } fn main() { run(); }