import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] arr = sc.next().toCharArray(); int count = 0; int one = 0; int nine = 0; for (char c : arr) { if (c == '1') { if (nine >= 2) { count++; nine -= 2; } else { one++; } } else if (c == '9') { if (one > 0) { count++; one--; } else { nine++; } } else { count++; } } count += one / 2; System.out.println(count); } }