import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String s = br.readLine(); br.close(); int[] cnt = new int[10]; for (int i = 0; i < n; i++) { cnt[s.charAt(i) - '0']++; } int ans = 0; ans += cnt[3]; ans += cnt[5]; ans += cnt[7]; int cnt1 = 0; int cnt9 = 0; for (int i = 0; i < n; i++) { if (s.charAt(i) == '1') { cnt1++; } else if (s.charAt(i) == '9') { if (cnt1 > 0) { ans++; cnt1--; } else { cnt9++; } } } int val1 = cnt1 / 2; if (cnt1 % 2 == 1 && cnt9 >= 2) { val1++; } int val2 = Math.min(cnt1, cnt9 / 2); ans += Math.max(val1, val2); System.out.println(ans); } }