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') { one++; } else if (c == '9') { if (one > 0) { count++; one--; } else { nine++; } } else { count++; } } int min = Math.min(nine / 2, one); count += min; one -= min; count += one / 2; System.out.println(count); } }