use std::io::Read; fn main() { let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let mut all_data = all_data.trim().split('\n').map(|s| s.trim()); let n: usize = all_data.next().unwrap().parse().unwrap(); let s: String = all_data.next().unwrap().chars() .filter(|c| c != &'3') .filter(|c| c != &'5') .filter(|c| c != &'7') .collect(); let mut count = n - s.len(); let mut one_count: usize = 0; let mut nine_count: usize = 0; for c in s.chars() { if c == '1' { one_count += 1; } else { if one_count > 0 { one_count -= 1; count += 1; } else { nine_count += 1; } } } let nno = std::cmp::min(nine_count / 2, one_count); println!("{}", count + nno + (one_count - nno) / 2); }